I have a hierarchical taxonomy download-category
from which I only want the posts with a parent term to show up:
$downloads_parent_posts = get_posts( array(
'post_type' => 'downloads',
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'download-category',
'terms' => $term->term_id,
'field' => 'term_id',
'include_children' => false
)
),
) );
This query works fine.
Now what I’d like to achieve is that only posts show up, that don’t have a child of the corresponding parent term applied.
For example I have a parent taxonomy term 'film' and a child term 'horror'. A post has both the parent term and the child term. This post should not show up in that query above.
Is it somehow possible to extend the query or add a condition which filters out the posts with a corresponding child term to the parent term?
Any help would be much appreciated.