How to filter by category in REST API, excluding posts also in other category term?

According to http://v2.wp-api.org/reference/posts/ you have categories_exclude available as a param to pass to the API.

This should work:

http://localhost/wp-json/wp/v2/events/?categories=23&categories_exclude=42&per_page=1

…to get the posts from category 23, but exclude those that also have 42 assigned as category.

Leave a Comment