If I have done a posts query which has fetched a long list of posts in to the WP_Object $all_posts
, how, during the output loop, can I pull the next five posts of $all_posts
in to new WP_Object $five_posts
?
I'm already successfully using a counter, $i
, in the loop to identify the position at which this should occur.
What I don't understand is how to get the next five posts in to a WP_Object
.
I have tried...
$five_posts = new WP_Query();
$five_posts->posts = array_slice(
$all_posts->posts,
$all_posts->current_position,
$all_posts->current_position + 5
);
But that results only in the [posts]
part of the query, sliced as an array, and omits the actual query data, which I'd like to retain.
So, basically, how do I extract five posts out of $all_posts
in a way that maintains $five_posts
as a full WP_Query
object?