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
- WP_Query offset returning duplicate posts from previous loops with AJAX
- Create a page template for “top rated posts” but show full content and not just a list
- has_excerpt() not working inside wp_query
- Apply query arguments after the nth post
- wp_query is showing posts from other categories
- Daily drip of posts – based on user ‘startData’ – ordered oldest to newest
- How to add tax_query to $args with concatenation
- Change AJAX filter from POST to GET for URL Parameters
- Should I reset $wp_query?
- Meta query compare for ID’s greater than specific ID
- Exclude a Woocommerce product from WP_Query
- WP ForLoop to compare meta information of posts to determine what post to display
- Loading two different AJAX requests on two different pages
- WP_QUERY wrong ammount of posts
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- How to add sort order to incremented and paginated category loop
- Apply filters to main query instead of creating new one?
- How does WP generate the default $query in WP_Query based on the URL?
- Continue or break the while loop
- How to filter query loop block with a search string from the query parameters
- inserting content of 1 Post to in another with a template hierarchy
- how to get category`s slug in WP_Query loop?
- Loop posts based on permalink term
- Page navigation doesn’t seem to work when I add offset?
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- How to split a post and intercalate elements from a loop
- How to remove only the latest sticky post from the loop
- Expecting statement error from php loop using ACF plugin
- Loop 3 posts column wise and continue the loop into same columns
- How to use a dropdown to filter posts by custom field
- How I can repeat 2 HTML templates in a WordPress Query?
- PHP – Loop custom post type categories within jQuery Tabs
- Check if a post has term inside loop
- How to create a widget like this?
- Does WP_Query ‘responds’ badly to empty arguments?
- Retrieve data from wordpress db via input and put those result in dropdown
- How do I sort this custom list of sticky posts
- WP_Query with one category in args shows other categories
- Query only displays one page_id
- How to Order By Two Custom Fields?
- Display specific page (that is child) content on parent page
- Different Loop for tag pages?
- Ordering posts by custom field and grouped by month
- Pagination for custom loop on custom page template is not displaying anything
- Does putting queries within loops cause an issue on WordPress?
- Filtering by multiple conditions in the loop
- Hiding carousel indicators if there’s only one post
- Query Taxonomy By Page Title
- WP_query is not returning the expected result
- How to access $wp_query object from array of posts given by get_posts?
- Function using get_posts() with tax_query not working when called from functions.php
- WordPress dynamic AJAX query
- Display all attached image of every post of custom post type and link to original post
- 2 queries with counters
- Get posts with no tags?
- ajax wp_query conditional tags not working
- wp-query, pull children of parent page
- I need to run a AJAX Fuction from within a WP_Query but only works on first item
- relation OR instead of AND – Filtered term ID’s in loop
- Writing less unnecessary code with WordPress
- Does query_posts have an effect on get_the_category?
- Second loop pagination changes URL, not content
- How to change the default post type over the loop?
- I am officially missing something about transient posts
- Query Not working as expected
- Compare “Main” post ID to ID inside wp_query loop
- WP_Query orderby random do not repeat infinite scroll – one loop
- Paginate pages with dynamic query
- WP_Query loop doen’t work with my custom taxonomy
- Advise on Templates for Custom Queries
- Search.php – return number of results but cannot loop through
- How do I get the content of a custom instance of WP_Query?
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Creating ‘posts page’ loop based on the page itself
- Why does apply_filters behave different inside and outside a loop?
- Change post query onclick
- WordPress Queries Not Working?
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Filter subpages in while loop from WP Query object
- Add AJAX “Load more” on custom query block
- 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
- wpquery via ajax