Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

is there a way I can retrieve the first and second post in wordpress...

I have tried using get_post() but with that I have to put in a id. What if I don't know the posts id?

share|improve this question
    
How do you define "first and second"? Earliest by date posted? –  Rarst Sep 28 '12 at 14:58

1 Answer 1

Have you tried using WP_Query()?

$query = new WP_Query( 'posts_per_page=2' );

You can also split it into two quieries if you must, with an offset:

$query = new WP_Query( 'posts_per_page' => 1 ) ); // First post
$query = new WP_Query( 'posts_per_page' => 1, 'offset=1' ) ); // Second post
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.