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 to query for the first three recent posts and then change how they display on the front page?

I want the first three posts of my blog to show differently than the rest of them i.e. they will have full images, and my other posts will just have thumbnail previews.

Thanks for any help in the matter.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can style the first 3 posts differently without querying them separately, you just need to check where you are within the loop while outputting each post via the built in current_post var.

while( have_posts() ):
    the_post();

    // are we on the first page and outputting one of the first 3 posts?
    if( !is_paged() && $wp_query->current_post < 3 ):
        // output full image, etc..
    else:
        // not first page and not first 3 posts
        // output just thumb, etc..
    endif;

endwhile;
share|improve this answer
    
Thanks a bunch, that is pretty simple! –  Romes Apr 9 '13 at 2:01

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.