0

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?

1
  • How do you define "first and second"? Earliest by date posted?
    – Rarst
    Commented Sep 28, 2012 at 14:58

1 Answer 1

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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