You need to create a new WP_Query
instance with the updated arguments. I will usually write it like this
$args = [
'post_type' => 'employee',
'post_status' => 'any',
'posts_per_page' => 10,
'paged' => 1,
];
$query = new WP_Query($args);
while ($query->have_posts()) {
// your logic goes here
// foreach ($query->posts as $custom_stuff) {}
// prepare for next loop iteration
$args['paged']++;
$query = new WP_Query($args);
}
When the first run is done, $args['paged']
is updated and the $query
variable is updated with a new WP_Query
instance. if $query->have_posts()
is true, the loop will then continue.