Get custom post type by custom taxonomy on the WordPress rest api

To get custom post types and filter them by custom taxonomies, you can do the following:


or filter by more than one taxonomy (this means: give me posts from taxonomy 1 OR 3 OR 6):


or to exclude posts with specific taxonomies:


Maybe good to know: combining categories and tags means AND, so for example the next URl means “give me posts that have categories 1 OR 2 AND also have tag 5”:


It is not possible with the default api to filter on custom taxonomies by using the slug name. For this to work, you can install the filter plugin or you have to write some code that uses the rest_{$this->post_type}_query filter.

 'my_plugin_rest_query_filter', 10, 2);

function my_plugin_rest_query_filter($args, $request) {
 if (!empty($request['custom_taxonomy_slug'])) {
 $args['tax_query'] = [
 'taxonomy' => 'custom_taxonomy',
 'field' => 'slug',
 'terms' => $request['custom_taxonomy_slug']
 return $args;