S
S
santime2018-06-07 08:48:24
WordPress
santime, 2018-06-07 08:48:24

How to paginate a custom query in WP_Query?

So, the logic is this:
There is a taxonomy page, where posts are displayed in the standard cycle.
On the same page there are checkboxes for filters, when you click on the checkbox, information about the category is sent by AJAX to the handler.
A new selection is made in the handler:

$query= new WP_Query(array(
  'post_type' => 'product',
  'posts_per_page' => get_option('posts_per_page'),
  'taxonomy_name1' => 'term_slug1',
  'taxonomy_name2' => 'term_slug2',
));

and then the records are stupidly returned via echo and output via JS .html()
It was more or less possible to make pagination for one term, but it’s not clear how to make pagination for a selection of several taxonomies and terms. (And in the future, sampling is also planned for arbitrary fields)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question