I am having a problem with two ajax action. I have a post grid it has a frontend sorting "ASC" and "DESC". So if I click on "DESC" it changes the WordPress query arg "order by" to "DESC". It works.

But I have load more button which is also ajax. It also works but it does not consider the above case it query args remain the same as initial. So if I click the DESC button and click load more it loads the second page without DESC into consideration.

Any possible workaround?

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.