0

Does anybody know if I can do an OR search in the URL like:

http://www.example.com/api/wp-json/wp/v2/books/?(filter[category_name]=anthropology&filter[category_name]=africa)|(filter[category_name]=anthropology&filter[category_name]=china)

(this example actually returns data but only the results for the second filter group (anthropology / china))

Any hints appreciated!

1
  • The category_name parameter takes a single string, and doesn't support an array as an argument, even if you get an array out of this WP_Query won't support that, you'll need to pass in IDs instead and use category__in
    – Tom J Nowell
    Oct 28, 2016 at 18:27

1 Answer 1

0

First (since 4.7.1) you will need to re-activate the filter parameter. Then make sure you have REST support activated for your custom post type (books).

Next you have to allowing the query args meta_query and parse it.

This answer shows how to do all this. Specifically, how to construct the meta query and the compare operators. : https://wordpress.stackexchange.com/a/227869/111022

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.