Your query doesn’t know anything about which posts you’ve already displayed. All it knows is that the second page of a 4 posts per page query is logically going to be posts 5-8. If you want to get a specific range of posts you should use offset
instead of paged
:
$args = [
'offset'. => absint( $_POST['offset'] ),
'post_status' => 'publish'
'post_type' => 'post',
'posts_per_page' => 4,
];
$ajax = new WP_Query($args);
You’ll just need to keep track of the appropriate offset on the front end.
Related Posts:
- Ajax Load More Posts in Category Page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- AJAX filter posts by year
- Storing posts from query and accessing later via AJAX call
- Ajax load more button in Recent posts widget
- WP_Query with ajax handler returns the same posts
- Ajaxify This Code
- Random ajax load only works with posts_per_page set to -1
- wp_query with ajax
- Call current post URL in ajax
- Ajax post doesnt call succes after got the response
- Ajaxify Post Sort
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- WP_Query extended with AJAX
- Gutenberg block: add a multi-select for posts
- Add scripts on custom post add/edit pages Not Working
- Only display a certain number of posts, dependent on how many posts there are available in a query
- How to create a load more post entries like Twitter?
- Injecting JavaScript into a Post with WP3.x
- How do I use `posts_distinct` correctly?
- How can I remove posts of a certain category from homepage after a specified time period?
- How can I get a post field value using javascript?
- Automatic value for custom fields for posts
- Loop through all product posts?
- Custom WP_QUERY $args
- Improving WP_Query for performance when random posts are ordered
- Automatic post deletion
- Why won’t my taxonomy query show up?
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Get random posts between specific dates / of specific age
- WP_Query get posts from custom posts by category
- Accessing post->ID outside of the loop for listing child pages
- How to find what index page a post is on?
- WP Query – duplicated posts once including tags in search results
- slideshow is not showing in a post call with ajax
- Limiting the number of posts in WP_Query leads to unexpected result
- how to set beforsend option in wordpress ajax methods
- Filter Custom Post Type by Category with Ajax
- List posts in a given category
- Ajax posts filter by date, comments, top views, top likes
- Add ajax load more function using WP API
- Reset Popular post query?
- How to pass Post_ID variable from theme’s Single.php to custom Plugin using AJAX
- Yearly archive page for future year
- Query Posts multiple conditions
- Display post from current category and same tag?
- how to get posts ids inside pre_get_posts filter?
- I want to get title name of post, but i didn’t get by this code. Any suggestion?
- Get Posts that are in the current month or later
- WP Query to Get Array of Slugs
- Custom post preview without saving
- JSON – Permission Error?
- Future post ID not showing
- How can I show many posts an author has per week?
- How do I use WP_Query to get a range of posts with custom fields that have numbers with letters in them?
- Ajax Dynamic Archives not showing correct results
- WP_Query orderby not working with meta_value_num and menu_order
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Custom WP_Query with complex ‘post_status’ argument
- How can I sort posts by the date and a custom meta field?
- is there a way to show the the post title after the image?
- recent posts for different categories
- Block Editor: Reset Reusable Blocks to last saved record
- Search by post title and content in wp_query without order
- Hiding Draft Post In Admin
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Blog post per page setting conflicting with custom WP_Query?
- Change post order random through out the entire WordPress
- How to insert 2 args into 1 Wp_Query for a slideshow
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Setup a custom dynamic post
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- How to verify wp user password by sql query in wp? [closed]
- JS innerhtml changing style when using AJAX
- Removing noindex posts from wp_query
- WP Query – Posts Per Page not working in combination with category__in
- Ajax post filters not working
- How to filter my search in post if contains a word in title, content or excerpt?
- How to return another post than requested
- Pausing and Resuming WP_Query results
- How to do set post permalinks using 6 digit random unique function?
- Select only post id and meta value with WP_Query
- Lost draft under all posts and drafts
- Get user categories with most posts in it
- Loading post with Ajax
- Integrate OpenStreetMap on WordPress
- Genesis + Ajax + Jquery | Failling to call action
- How to : pagination in 3 different custom loops on the same page
- Send post id through ajax and get the post content back
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- Exclude the first ‘n’ number of posts of a tag from home page?
- Query posts and return XML
- Using ajax on editing a category edit page?
- how to change the number of posts returned in a specific loop without making it global?
- Query Posts With Over 1000 Views
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- posts_per_page option limits the number of Gallery items
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title