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?

  • How do you define "first and second"? Earliest by date posted? – Rarst Sep 28 '12 at 14:58
2

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, privacy policy and cookie policy

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