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 on a WP_query not showing navigation links
- How to paginate wordpress [gallery] shortcode?
- paginate_links ignore my format
- wp_query->max_num_pages always returns 0 on custom post type
- How to paginate attachments in a secondary query as gallery?
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Load more AJAX on WP Query
- Pagination not working for Custom search form & custom result template
- How to adjust found_posts so that it accounts for offset and pagination
- 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
- 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`
- Using AJAX to return search form results
- Two queries on the same page with pagination
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- 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]
- Pagination for custom query on single.php
- Pagination doesn’t work in custom page template [duplicate]
- 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?
- Too many posts cause slow load when paginating
- How to output different posts per page?
- Multiple WP_Query loops with Pagination Not Working
- Custom pagination with WP_Query generating 404 error
- Show selected images on top in Media Manager
- Offset Page Loops and Pagination
- How to set pagination to work with ‘/page/’?
- Get pagination working for custom loops within page templates
- WP_Query Pagination on multiple-loop page breaks WP or doesn’t show up
- Using ajax with paging and a custom sub-query
- pagination with ‘no_found_rows’ => true,
- Ajax WP_Query reutrns no results on author.php
- Pagination links missing for first link (1) and previous button? How to get pagination links to work?
- How to return a 404 when custom query matches nothing?
- Pretty urls for custom pagination
- Multisite pagination issue by multi query archive 404
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Pagination for blog posts reloading same page [closed]
- Ajax future single post query doesn’t work when NOT logged in
- Append URL query to next post link in custom query
- new WP_Query messes up pagination
- Pagination is not working with custom query inside a homepage template
- Display single most recent post in category on every page of category archive
- Pagination works in custom query loop but it doesn’t work in shortcode
- How to use a dropdown to filter posts by custom field
- Retrieve data from wordpress db via input and put those result in dropdown
- Content not displaying on paginated page
- WP_query is not returning the expected result
- I need to run a AJAX Fuction from within a WP_Query but only works on first item
- I am officially missing something about transient posts
- Adding pagination to sub-wp_query within a singular post page
- WP_Query and pagination AGAIN?
- Reciving Error 404 blog/page/2/
- duplicated posts when using pagination
- wordpress pagination wont render on custom page template even though its right under the loop like the documentation says so
- Load more posts using AJAX based on posts inside WP_Query
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Pagination repeating posts on search results
- Filter admin ajax data by url query
- Pagination for Category does not work
- Load WP Query with Ajax
- pagination functions are not working
- WordPress pagination not returning posts on second page
- Is instantiating WP_Query not possible within an admin Ajax call?
- WordPress conflict with multiple load more posts functions on click
- Show All with Isotope
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- 3 wp_query on one page with pagination for last query
- Custom pagination (Title, date and teaser)
- WP_Query for liked posts is showing all posts if none are liked
- Declare inline background image in functions.php
- custom query – offset to pagination
- previous_posts_link not working in WordPress pagination
- Add pagination to table generated by wp_query
- Pagination in custom query in a category page
- Fire query on ajax post url page
- What is wrong with this pagination code?
- Can’t get pagination to work with this WP_Query loop
- Pagination in custom loop [duplicate]
- Pagination in WP query with transient API
- paginate_links() with Custom Taxonomy
- Multiple loops on index page with sticky post and pagination
- Pagination not working in secondary query
- WP Paginate not working properly
- Pagenavi with archive page
- AJAX search function resets wp_query vars
- WordPress Ajax search filter on dropdown select