Search for Content Across Post Types With WordPress REST API
The WordPress REST API is extremely powerful but can be really confusing. For me, one of the most confusing aspects is that each post type is set up with its own endpoint. Luckily, there is a search endpoint that can access content across multiple post types. Here are some helpful examples for searching for content in WordPress using the REST API.
WordPress REST API Search Result Endpoint Examples
Request to Search for a Term in All Post Types
/wp-json/wp/v2/search/?search=searchterm
Request to Search for a Term and Limit Results to a Single Custom Post Type
/wp-json/wp/v2/search/?subtype=book&search=searchterm
Request to Search For a Term and Limit Results to Multiple Custom Post Types
/wp-json/wp/v2/search/?subtype[]=book&subtype[]=movie&search=searchterm