You can use wp_localize_script
to save your current query to JS variable. Then you should send it using ajax and modify it and send it back to have access to it in the future.
global $wp_query;
wp_localize_script( 'ajax-pagination', 'ajaxpagination', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'query_vars' => json_encode( $wp_query->query )
));
This article should help you handle the issue. Especially part with query_vars there is quite good explanation.
Related Posts:
- Ajax Infinite Scroll In Custom WP_Query Loop Not Working
- AJAX Breaking Offset Argument In WP Query
- 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
- How to solve this script problem in theme directory?
- Sorting Posts Based On Meta Value Using AJAX
- Can I force WP_Query to return no results?
- Multiple WP_Query loops with Pagination
- WP_Query and next_posts_link
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Get array of posts from the current archive page loop
- How can I save an array from a random post sequence for later use?
- In loop: posts have thumbnail AND other variables
- How to order category.php loop by ‘meta_value’?
- Add inline HTML to posts published within last 24hrs
- Move posts to top of WP_Query if in certain Taxonomy?
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- WP_Query orderby breaks when using AJAX?
- Implementing an OR statement to wordpress wp_query
- Get List of all the Authors
- WP_Query loop within WP_Query loop
- Refine search results using WP_Query
- How to pass many ids in post__in?
- How to use WP_Query to display many posts?
- How to show subcategories using loop?
- Sub-loop / nested loops Best Practices
- Five posts from a category in footer
- Show Sticky Post at the top but do not show again in the loop?
- Any number in meta key (wp query)
- How do I run through a WordPress loop called from a filter function?
- How do I get the title of a category in a custom loop?
- Load More Posts Button – AJAX
- Order by empty custom field
- Out Of memory issue on post per page parameter
- Check if loop has any categories?
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Current post in AJAX call is always zero
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- New WP_Query loop in admin causes problems
- Change query from cat id to slug or name?
- Using Wp_Query without the loop?
- how update data through ajax and jquery
- Custom WP_Query id
- Assign custom parameter to each post in query
- posts archive page – closing WP_Query loop correctly [closed]
- Loading two different AJAX requests on two different pages
- How does WP generate the default $query in WP_Query based on the URL?
- Continue or break the while loop
- how to get category`s slug in WP_Query loop?
- How to remove only the latest sticky post from the loop
- How I can repeat 2 HTML templates in a WordPress Query?
- Offset WP_Query by negative 1
- WP_Query orderby random do not repeat infinite scroll – one loop
- Advise on Templates for Custom Queries
- Query WP Page for Buddypress Group Home [closed]
- $post in wp_query?
- How to make the ‘request’ filter work?
- JOIN filter doesn’t work in WP_Query in wp-ajax calls
- How to separate two columns from one content on a page template?
- WordPress Ajax form filter | Search by title with ajax form, breaks the other filters
- Why when I using infinity scroll the one post loads over and over?
- Filtering posts based on three taxonomies
- Can I alter the main loop to ‘orderby’ a custom callback?
- WordPress live search and filter custom fields
- Avoid removing duplicate posts
- Finding post ID dynamically on click
- how to get custom attachment url?
- WP_Query & Duplicate entries
- Regarding a custom loop and output HTML tags
- Repeat array inside array through while loop
- What’s causing an infinite loop?
- pages shortcode filtering by category
- Second WP_Query loop shows data from main query
- Meta Query if Values Don’t Exist
- Get post Number with local loop and template
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- WordPress custom query by archive title
- query_posts() doesn’t seem to be called in my page
- Fetching $_POST from Page Template into functions.php
- Pagination returns 404 after page 20
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- WP_Query a custom field value bringing back 0 results
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Inline Ajax call after term is appended with a @ or # etc. displayed in div
- Next / previous posts link doesn’t show up with Posts 2 Posts
- meta_query dates from an array
- Creating array to compare custom field values
- Carousel Loop only duplicating
- Remove 5 latest posts from the loop
- Exclude post formats in custom loop
- How to show featured post first, then separate loop for other posts
- Show linked products using wp query and woocommerce
- Standard Loop – wp_query
- Custom Wp_query loop takes very long
- Refresh wp_query with no changes
- Custom query for certain post type OR another post type with a certain category
- Pagination only showed when no category is set in wp_query