I’ve a custom WP_Query something like this:

$query_args = array(
    'post_type'         => 'post',
    'cat'               => 12,
    'posts_per_page'    => 5
);

$custom_query = new WP_Query($query_args);

Now, I need to split the results of this query in 3 sets, first set will have the first post only, the second set will have 2nd and 3rd posts and then the third set will have 4th and 5th posts.

The reason for this split is that entries in each set will have different outer and inner markup, outer markup is something like this:

<div class="column" data-span="6">1st Post Here</div>   

<div class="column" data-span="3">2nd + 3rd Posts Here</div>

<div class="column" data-span="3">4th + 5th Posts Here</div>

Is there is any way to print 1st post in the first div, pause the query, then resume the query in the second div, pause and the further resume the query in the third div?

Read more here: Pausing and Resuming WP_Query results


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: