I am looking for a way to run a global search query across all or multiple post types using WP REST API.
I am able to search posts using:
http://example.com/wp-json/wp/v2/posts?search=test
In turn I am able to search pages using:
http://example.com/wp-json/wp/v2/pages?search=test
How do I search across both posts and pages? I was able to do this in WP REST API V1 by specifying multiple type[]
variables in the query?
This might be a bit late but there is an endpoint for that in the v2-api: /wp-json/wp/v2/search
.
You can search for any specific post_type
by supplying it via subtype
or leave it to the default (any
) to search in all post_types.
Edit: Of course you can also specifiy multiple with an array as you did before.