Wordpress - WP REST API no longer supports filter param, so how do I get posts in a custom taxonomy?

Since WordPress 4.7 the filter argument for any post endpoint was removed. But if you need them, add them via plugin. The WP API Repo have a plugin 'Rest Filter' for this job, small and short.


The WordPress REST API documentation has a section on registering custom posts and taxonomies with the API. Essentially, you add 'show_in_rest' => true when registering the custom post type or custom taxonomy.

register_taxonomy('instance', ['post'], [
    <other args...>,
    'show_in_rest' => true,
]);

Once that's done, you can filter any object for which you registered that taxonomy ('post' in the above example) by that custom taxonomy by using its name as a query string parameter, e.g.:

https://example.com/wp-json/wp/v2/posts?instance=1

Note that the value of the taxonomy parameter ('1' in the above example) has to be the id of the taxonomy object, not it's name or slug. If you only know the slug, and not the id, you can first lookup the id by separately querying for it, because registering your custom taxonomy with the API also creates its own custom endpoint:

https://example.com/wp-json/wp/v2/instance?slug=foo-bar