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?
- 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
- Refine/Filter WP_Query Posts with jQuery or Ajax
- 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
- Storing query variable and then using wp_reset_query
- 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
- Get a list of posts with associated meta_value
- Ajax WP_Query reutrns no results on author.php
- Custom taxonomy.php not working
- different for loop if screen resolution < 1000px
- Transient api Caches confused
- Ajax future single post query doesn’t work when NOT logged in
- get_template_part causes 500 error
- sort and display posts by custom field (wp-query and the loop))
- wp_query is showing posts from other categories
- WP_QUERY wrong ammount of posts
- How to add sort order to incremented and paginated category loop
- how to get category`s slug in WP_Query loop?
- Page navigation doesn’t seem to work when I add offset?
- Expecting statement error from php loop using ACF plugin
- How do I sort this custom list of sticky posts
- Query only displays one page_id
- Get posts with no tags?
- wp-query, pull children of parent page
- I am officially missing something about transient posts
- Advise on Templates for Custom Queries
- How do I get the content of a custom instance of WP_Query?
- Change post query onclick
- Query WP Page for Buddypress Group Home [closed]
- How to separate two columns from one content on a page template?
- Using Ajax and WP_Query to load more posts on category page fails
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Filtering posts based on three taxonomies
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- WordPress live search and filter custom fields
- Show a message if there are no active posts in category
- Avoid removing duplicate posts
- Problem with my loops
- display the children of the post using the current page as the main parent
- Display 3 levels of categories on page
- Paging works correctly on local version, but not live?
- Custom post type loop error: Trying to get property of non-object
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Display three sequential posts on each page load, without repeating previous
- how to avoid reloading/refresh the page when displaying the post of wp_list_categories
- Featured Image as Background with Offset
- How to make a wordpress loop file that displays posts based on certain conditions
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Issue in If else condition [closed]
- Pagination not working with WP_QUERY
- Custom search (wp query by custom fields)
- How do I display posts with specific value in a custom field into my loop?
- Limit the number of posts from a specific category on index.php
- Order by multiple meta keys on wordpress
- wp_query pagination links producing 404
- How return normal search result using wp_ajax action for wordpress
- Display First posts without the default featured image
- Pagination problem with multiple loops on the same page
- Can’t seem to get an else statement correct? [closed]
- Output ACF field dynamicaly within a taxonomy loop [closed]
- How do I split a large query with a semi-expensive function included into multiple smaller queries
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen