Exclude posts in child taxonomies from custom taxonomy query
-
My WordPress theme has a custom taxonomy called “Collections”. The custom taxonomy is hierarchical, so there are subcollections.
I have a Collection called “Books” and a sub-collection called “Novels”. There are some posts that are just in “Books”, and some posts that are in “Novels”. I want the page for the “Books” collection to only show posts in the main “Books” collection, not the ones in the “Novels” subcollection. But by default, WordPress includes posts in “subcollections” in the query for a taxonomy.
How do I exclude posts in child terms from my taxonomy query? This is easy with categories, but it seems there is no built in way to do this with custom taxonomies.
- The topic ‘Exclude posts in child taxonomies from custom taxonomy query’ is closed to new replies.