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.
Related Posts:
- Inject post (from specific category) between posts in Loop
- Count number of published posts by type
- Get taxonomy terms only of the WP_Query current posts
- Hide post if matches current month and year
- How can I use wp_query to show all product data using just the products ID?
- How to store post ID’s in cookie or session to display the same posts later
- WP_Query: getting posts where custom field exists
- Array to string conversion on array_map
- Store metakey value as an array
- Modify main query before it run without pre_get_post
- Do not duplicate posts with multiple categories in multiple loops
- array_rand not working correctly?
- WP_Query() load selected post
- Wp Query : Order by distance lat,lon
- WordPress sorting posts by date and title using a dropdown
- posts_per_page displays only 2 posts instead of 4 posts
- Query on a repeater date (acf)
- Need to show 7 posts from actual date
- Check the database for a postmeta field
- Getting info about selected posts using one WP_Query
- How to display last whole post on the homepage
- Only Get A Certain Number of Posts From WP_Query
- insert thumbnail image from php script
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Query category-specific, paginated posts and allow viewer to change sort order
- Why does WP_Query show only the same post even with different categories and endwhile?
- How to modify this function to exclude also the post belonging to a specific category?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Insert code when users come from an specific referer
- How to display related posts from parent category
- Duplicates with WP_Query loop
- Make custom field meta not display if there is not data in it
- Display related products with custom output
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- Can’t search posts using WP_QUERY inside AJAX Function
- How to query for posts with a null or blank post_name?
- WordPress pagination not working with search page
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Loop through categories and display posts title under each dropdown
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- auto-populating custom nav with all items from custom post type
- List authors with the last post title and order by last post date
- How to get all author posts outside of author templates
- How to get post ID in a Page?
- Automatically add images to a menu
- How to override url params with rewrite rules vars?
- How to display SQL query that ran in WC_Order_Query?
- WP_Query multiple post results
- create front-end users post list by specific category
- Error display post thumbnails for previous and next post
- echo var into wp_query
- form $_post action value gets truncated after it passes through two forms
- Toolbar Hidden in a Virtual Page
- Let current user know pending posts counts using wp_query
- Add posts to custom table in database instead of wp_posts
- get_terms with specific id order
- get value from get_post_meta then reuse it in another get_post_meta
- WordPress Post Block Element not properly parsed with the_content filter
- get different meta-data of a complicated query at the same time
- Build A Custom SQL Query for WordPress Search
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- Using a new WP_Query inside the loop
- How to Send Pingbacks for all Posts in WordPress?
- Display articles with a different template in the home page | Solved |
- How can I check if a post with a particular slug or title exists?
- How to get specific multiple pages excerpts at homepage?
- Trying to get post ID outside loop on blog page
- Enqueue script only on child pages of custom post types
- Attach and retrive multiple pdf files to post or page
- Wp-query output correct, but the loop shows one less item (only sometimes)
- Get list of posts from attachment
- How to display sticky post always at the top (before regular post) in wordpress?
- When working with a post, almost all wp_postmeta are deleted
- How to get the posts that my following users are liked?
- Displaying POST content with HTML tags and all
- Pagination in WP Queries
- Add div after every 4 posts then every 2 posts for a responsive loop
- Only display notification on single post
- Transfer WordPress Login Session to an Extended Webpage on the Same Domain
- direct query to post_meta table
- Get posts associated with media attachment
- Can’t put a hyperlink on Featured Post’s Image
- WordPress get_post_meta issue
- List sibling pages widget, exclude current page
- Display pages from specific page template
- Does wp_query and query_posts affect website performance? [duplicate]
- WordPress post pagination on custom template not working
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- How to display the date under the post title?
- Changing regular db connection to $wpdb
- XML WP_Query problem in PHP 8.0 and 8.1
- How do I display WooCommerce products in my query to rows of 3?
- How to get ACF field to show up on all posts on front end?
- AND and OR in my CPT search query depending on checkbox
- How can I save the HTML output of a WP_Query function as a variable?
- How do I use fields => ids in an array with WP Query?