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
- Random sort within an already sorted query
- Search by Hyphen
- Exclude drafts in all() view of edit.php
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- How to query posts with current or future date only
- WordPress Number of Posts Not Changing With posts_per_page
- Create new WordPress post [wp_insert_post] based on results of a WP_Query
- Exclude posts with specific meta_value while sorting by a separate meta_value
- POST from jQuery to PHP
- Display the latest posts, published in the last hour, with WP_Query
- Custom Order in WP Query
- Fetch posts from current week (Sunday to Saturday)
- Search query – exact post title match
- Convert a complex webpage into WP theme
- Converting multiple loops into one single loop with pagination
- How would I get 1 latest post from a query for 5 posts?
- How to get most recent commented post above new submitted post in WordPress?
- Exclude posts with empty post_content in wp_query
- Exclude posts from featuring
- Lazy Load using WP_Query pagination
- Only display a certain number of posts, dependent on how many posts there are available in a query
- Automatic post deletion
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- How to pass Post_ID variable from theme’s Single.php to custom Plugin using AJAX
- Yearly archive page for future year
- Custom post preview without saving
- How can I show many posts an author has per week?
- WP_Query orderby not working with meta_value_num and menu_order
- Custom WP_Query with complex ‘post_status’ argument
- is there a way to show the the post title after the image?
- 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?
- How to exclude latest x posts from a paginated query?
- Select only post id and meta value with WP_Query
- Send post id through ajax and get the post content back
- How do I extract just the post ID of the first item in whatever WP_Query returns?
- Show post content and title in diferent divs using WP_Query using a loop
- How to get posts published on the latest date?
- Page and post loop same template
- Show metabox value last post excerpt, title and link
- Loading two different AJAX requests on two different pages
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- Related Posts function not working
- Conflict array_splice on loop and query in widget
- wp_query if have posts show date but not in loop
- Custom WP_Query not working correctly
- Echo the number of posts being displayed
- Creating a related posts section in wordpress inside a default post
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- Insert JavaScript in a blog post or a new page?
- How to make ajax load posts from the current category?
- Why is it recommended to insert JS through the theme, plugin, etc rather than in the post directly?
- While loop in functions.php outputting the_title() of each post on frontpage
- Why sorting posts doesn’t work properly?
- How to create loop of posts except post ID defined via ACF field
- the wp_post_update isn’t working all the time
- How to create custom search form function including post “tags”
- how to filter posts by category without page load (ajax) in wordpress?
- Display specific posts based on an ID of another post
- Change URL of previous posts and next posts link in WordPress
- How to invoke a HTML custom button based on a HTML dropdownlist menu
- long-title posts do not want published
- Many buttons not functioning in WordPress dashboard (as admin)
- Post data across WordPress sites
- Mix post date with post meta value using WP_Query
- Custom Post type Ajax search results
- Fill the exclude array() in get_posts()
- The first post appears twice
- WP_Query sort by meta_value_num or date
- testing result of $.post with json_encode
- Displaying a specific sub-category’s posts from wp_query
- Custom layout manager for posts
- Get results from the main wp_query
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Pagination for custom query won’t let me back on page 1
- Get post id on click of thumbnail
- Can’t get pagination to work
- How to get single post by one author?
- Order by ‘s’ using WP_Query()
- how to print loops for odd in 1st column and even in 2nd column in wordpress [closed]
- Wp_query WooCommerce products
- Next and Previous buttons are not showing on home page for post
- How edit footer copyright info? [closed]
- date_query returning only the most recent post instead of the post published before today
- Code understanding
- Default post showing more than intended