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.

I'd like to make my most recent article display a large with a larger thumbnail and with more content, while the rest of the posts in the loop show a small thumbnail and only the title with no content.

Is there a way I can do this in one while(have_posts()) loop?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

check the built in counter $wp_query->current_post within the loop:

<?php
while( have_posts() ) :
    the_post();

    if( 0 == $wp_query->current_post ):
        // this is the first post in the loop, output larger size, full content, etc.
    else:
        // output regular size, the_excerpt, etc.
    endif;

endwhile;
?>
share|improve this answer
add comment

I'm no wordpress expert but could you use 2 loops one showing the latest post and one showing posts after in order to have the different CSS?

So loop for most recent ...

    <?php $my_query = new WP_Query('showposts=1');
       while ($my_query->have_posts()) : $my_query->the_post(); ...

And the second loop (offsets the posts by 1)

    <?php $offset = new WP_Query('offset=1&showposts=5');
    while ($offset ->have_posts()) : $offset->the_post()...

You can change showposts=5 to show the number of posts you want in the remaining loop.

share|improve this answer
add comment

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.