Two Groups of Recent Posts with Different Styles (2 posts)

  1. Jay Hoffmann
    Posted 3 years ago #

    Does anyone know if there is a way to have two different groups of Recent Posts, each under a different <div> with different styles.

    For instance, let's say I would like to display 10 posts on my homepage. The first 5 I would like to display with a post thumbnail and with larger type. The last 5 I would like to display in list form with smaller type. How can I achieve this, it seems every time I try to call
    <?php while (havepots()) : the_post(); ?>
    a second time, it automatically rewinds the listing and shows the same 5 posts twice.


  2. Michael
    Forum Moderator
    Posted 3 years ago #

    one possibility is to use a counter with a conditional statement, with which you show a different output for the first five posts.

    or use the variable $wp_query->current_post (which indicates the post's position in the loop, starting with 0 zero for the first post) within a conditional statement;


    ... while( have_poosts() ) : the_post();
    if( $wp_query->current_post < 5 ) {
    //output layout for first five posts//
    } else {
    //output layout for the rest//
    endwhile; ....

Topic Closed

This topic has been closed to new replies.

About this Topic