Support » Plugins » Two Groups of Recent Posts with Different Styles

  • 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.

    Thanks

Viewing 1 replies (of 1 total)
  • 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;

    example:

    ... while( have_poosts() ) : the_post();
    if( $wp_query->current_post < 5 ) {
    //output layout for first five posts//
    } else {
    //output layout for the rest//
    }
    endwhile; ....
Viewing 1 replies (of 1 total)
  • The topic ‘Two Groups of Recent Posts with Different Styles’ is closed to new replies.