Missing the first 6 Posts and displaying posts that are after the latest 6

You don’t need to make them separate queries. Query for all 12 posts, when you output them in the first section only output them if $wp_query->current_post < 6, then rewind_posts() and run the loop again, only outputting them in the second section if $wp_query->current_post > 5. If you are using a custom WP_Query, swap $wp_query with whatever your custom query object is named. Using the method of checking which post you are currently outputting, you could probably even just do it in a single loop.

EDIT – example. note that current_post starts at zero, so it’s equal to 5 on the sixth post:

$the_query = new WP_Query( array(
    'posts_per_page' => 15
) );

while ( $the_query->have_posts() ) :
    $the_query->the_post();

    if( $the_query->current_post < 6 ) :

        // This is one of the first 6 posts
        // Output the thumbnail, title, etc..

    endif;

    if( $the_query->current_post == 5 ) :

        // The sixth post has been output,
        // output the header/opening container
        // for all the other posts

    endif;

    if( $the_query->current_post > 5 ) :

        // This is post 7 and greater
        // Output just the title, etc..

    endif;

endwhile;

Example 2 – using rewind_posts and running the same loop twice:

$the_query = new WP_Query( array(
    'posts_per_page' => 15
) );

while ( $the_query->have_posts() ) :
    $the_query->the_post();

    if( $the_query->current_post < 6 ) :

        // This is one of the first 6 posts
        // Output the thumbnail, title, etc..

    endif;

endwhile;

// rewind the loop to run it again
$the_query->rewind_posts();

while ( $the_query->have_posts() ) :
    $the_query->the_post();

    if( $the_query->current_post > 5 ) :

        // This is post 7 and greater
        // Output just the title, etc..

    endif;

endwhile;

Leave a Comment