So I’m guessing this is a follow-up to this question. And based on my answer there, you can use/add the offset parameter like so:
-
In
category.php, just set the preferred offset:$the_query = new WP_Query( array( 'category__in' => array( $cat_id ), 'post_type' => 'post', 'posts_per_page' => 5, 'paged' => $current_page, 'offset' => 1, // set offset ) ); -
In
misha_loadmore_ajax_handler()(the PHP function which processes the AJAX requests), add this right before$the_query = new WP_Query( $args );:if ( isset( $args['offset'] ) ) { $offset = absint( $args['offset'] ); $args['offset'] = absint( ( $args['paged'] - 1 ) * $args['posts_per_page'] ) + $offset; }
That’s all. No changes necessary in the JavaScript parts.
Related Posts:
- Ajax Infinite Scroll In Custom WP_Query Loop Not Working
- Exclude first 5 posts of specific categories in the main loop
- How to use offset in WP_Query
- How do I rewrite this loop as a new WP_Query style-loop?
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- WP_Query offset is returning post from prevois loop
- Offset WP_Query by negative 1
- How to pass the current content of $wp_query to a new page?
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- modifying the loop multiple times with arguments passed through ajax to wp_query
- How to solve this script problem in theme directory?
- WordPress WP_Query offset parameter not working with search parameter
- Sorting Posts Based On Meta Value Using AJAX
- Some doubts about how the main query and the custom query works in this custom theme?
- Using a custom WP_Query with get_template_part loop
- Loop within a loop?
- Use WP_Query with have_posts()?
- ajax category filter
- Display posts the match taxonomy term linked from wp_list_categoies?
- Ajax and WP_Query/tax_query parameter
- Merging a complex query with post_rewind and splitting posts into two columns
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Pagination Not working on Home Page with 2 Query
- ‘posts_where’ filter not applying ‘WP_Query’ in `wp_ajax`
- meta_query not working properly
- Exclude post on loop by multiple meta key value
- Sort by meta key on archive page
- Query sticky posts with thumbnails
- Show all parents and children in custom post type in right order
- Why is this coming back as null? Thats wrong. There is one post
- Ignore post by meta value in the main query
- Update Loop with Form
- WP_Query to get posts in a specific category and post format
- Refine/Filter WP_Query Posts with jQuery or Ajax
- Can’t get drafts with WP_Query using post_status parameter
- How to retrieve current page WP_Query arguments?
- Show selected images on top in Media Manager
- How to limit WP_Query to one result on the loop?
- Random loop with code to prevent duplicate output returns no output at all from time to time
- How can I fix: “Notice: Undefined offset: 0”?
- Multiple loops without repeating content
- WP_Query, pre_get_posts and offset
- Filtering posts from different categories into different section by doing WP_Query only once
- Ajax WP_Query reutrns no results on author.php
- How to list posts with disabled/closed comments, with pagination?
- How to make a second query offset -2 from current post
- WP_Query with offset and ‘orderby’ => ‘rand’, offset not working
- WP_Query arguments order
- Best choice for multiple loop in page?
- WP Query – order posts by meta field first and then order the rest
- Wp_query with 2 meta keys and array of meta values
- How to create custom query by keyword in post title?
- Create a loop on my pages with new “WP_Query”
- WP ForLoop to compare meta information of posts to determine what post to display
- inserting content of 1 Post to in another with a template hierarchy
- Page navigation doesn’t seem to work when I add offset?
- Retrieve data from wordpress db via input and put those result in dropdown
- Pagination for custom loop on custom page template is not displaying anything
- Filtering by multiple conditions in the loop
- How to access $wp_query object from array of posts given by get_posts?
- Display all attached image of every post of custom post type and link to original post
- I need to run a AJAX Fuction from within a WP_Query but only works on first item
- Writing less unnecessary code with WordPress
- WordPress Queries Not Working?
- Filter subpages in while loop from WP Query object
- How to filter a static post page with ajax and $wp_query
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- Custom query does not find pages
- How to sort by most watched in X days/months
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- How can I use arrays and a foreach to generate many lists with WP_Query?
- Using Ajax and WP_Query to load more posts on category page fails
- How to use custom page for all posts with custom url, call another directory?
- display ACF repater field in archive page
- WP_Query breaking the loop in a nested loop
- Filter admin ajax data by url query
- Related posts queries
- update_post_meta() not updating
- Paging works correctly on local version, but not live?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Is instantiating WP_Query not possible within an admin Ajax call?
- WordPress conflict with multiple load more posts functions on click
- why default wordpress loop not working outside index.php
- how to show more than 1 post into three columns query
- Show All with Isotope
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- active link for most recent post on vertical tabs
- WP_Query for liked posts is showing all posts if none are liked
- custom query – offset to pagination
- wp_query pagination links producing 404
- How return normal search result using wp_ajax action for wordpress
- How ‘secure’ are loops?
- Pagination problem with multiple loops on the same page
- How to do a loop inside a loop?
- Main loop querying current template’s info only in custom category archive pages, not my posts
- How can I display sticky posts at first in wp_query?
- Custom query for certain post type OR another post type with a certain category
- Splitting query results, on the frontend, into separate sections based on meta value without multiple loops?