If you have a form you should have a sort field in it, so that you can send your order value on form submit. This way you can send the sorting parameter to your backend callback function.
If you don’t have a form you shoud add this parameter to another element with a data attribute like that:
<button id="load-more" data-order="DESC">Load More</button>
And then in your javascript code add this value to the ajax call parameters.
Remember that you should change this parameter when you call ajax for sorting.
Related Posts:
- next_posts_link not working for loop called with ajax
- Search – Ajax – Alter Query Parameters with Pagination
- WP_Query ajax loader detect end of posts
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- How to filter a static post page with ajax and $wp_query
- Ajax (jquery) wp_query pagination returns -1
- Duplicate posts showing up in loop using infinite scroll
- Pagination when using wp_query?
- How can i retrieve default post per page value? from settings->reading. And total number of posts?
- Find out total number of pages in global query on archive page?
- Post_count only shows the number of results per page
- Multiple WP_Query loops with Pagination
- Pagination with custom SQL query
- WordPress Pagination Not Working – Always Showing First Pages Content
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- Pagination on a WP_query not showing navigation links
- Different ‘posts_per_page’ setting for first, and rest of the paginated pages?
- How to paginate wordpress [gallery] shortcode?
- Pagination returns 404 after page 20
- paginate_links() adds empty href to first page and previous link
- paginate_links ignore my format
- Combining two wordpress queries with pagination is not working
- Custom WP_Query order by post_meta and (author) user_meta
- wp_query->max_num_pages always returns 0 on custom post type
- How to paginate attachments in a secondary query as gallery?
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- ajax category filter
- WP_Query and Pagination on a Static front page
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Why does pagination always break when used on any form of a home page?
- Ajax and WP_Query/tax_query parameter
- Pagination with 5 posts per page
- Load more AJAX on WP Query
- Pagination shows 404 after a certain number of pages
- Pagination custom query
- Pagination not working for Custom search form & custom result template
- Pagination/infinite scroll with WP_Query and multiple loops
- get data from wp-query, outside the loop & without url change
- How to adjust found_posts so that it accounts for offset and pagination
- Pagination broken when merging search results with additional WP_Query
- WP_query and pagination?
- pagenavi with merged wp_query [duplicate]
- Add and in the header while looping over custom query in page template
- pagination doesn’t show up for custom post type
- Pagination causes error 404 when used with front-page.php
- How to pass custom parameter to WP_Query for filtering in pre_get_posts
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- Paginated pages are showing correct content but pagination links are not
- Query with pre_get_posts to get pagination
- Pagination wont work with search results template [duplicate]
- Pagination Not working on Home Page with 2 Query
- ‘posts_where’ filter not applying ‘WP_Query’ in `wp_ajax`
- Ajax Infinite Scroll In Custom WP_Query Loop Not Working
- Best Practice For Querying Grandchildren?
- Pagination not working on static page
- ‘paged’ in wp_query doesn’t work
- Display different number of posts from one category on the different pages
- Using AJAX to return search form results
- Pagination not working Search posts
- Pagination not working for category posts
- Pagination is not working using WP_Query
- WP Query with offset breaks wp_pagenavi or any pagination
- WP_Query class not found
- Two queries on the same page with pagination
- Transient pagination not working properly
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- Show single post then all posts (with pagination)
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- Add custom search results to main WP search [duplicate]
- Woocommerce custom loop to show all the products [closed]
- How to bring specific post to front of wordpress loop?
- Pagination for custom query on single.php
- How to wp_query posts with ajax
- Merged two WP_Queries, posts per page and pagination not working
- Pagination doesn’t work in custom page template [duplicate]
- Intentionally exceed max_num_pages on main query without getting 404?
- WP_Query pagination not working in admin area
- Pagination 404 errors for author posts query on author.php
- WordPress pagination link always leads to home page
- WP_Query orderby breaks when using AJAX?
- How to get user_id from wordpress database inside ajax function?
- WP_QUERY loop, offset in the arguments and the paginate_links – can these work together?
- Pagination problem after WP_Query with tag filtering
- Too many posts cause slow load when paginating
- Pagination stops at page 6
- Paginated HTML Sitemap
- Update Loop with Form
- How to output different posts per page?
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- Custom pagination with WP_Query generating 404 error
- WP_Query & AJAX
- Sticky Post default functionality with WP_Query is ignored when using AJAX
- Pagination working everywhere but the index page
- Refine/Filter WP_Query Posts with jQuery or Ajax
- Show selected images on top in Media Manager
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX