Query 1 taxonomy term, exclude another
Here's the code I'm using to try and query a single taxonomy for one term, but exclude returned posts for that term that also belong to another.
In English, this is what I want: query 'resource-type' for 'testimonies', but not 'testimonies' that are also 'audio'.
Tips to tweak this code to get it to work?
?php
$testimonials_args = array(
'post_type' = 'resource',
'posts_per_page' = 1,
'tax_query' = array(
'relation' = 'AND',
array(
'taxonomy' = 'resource-type',
'field' = 'slug',
'terms' = array( 'testimonies' )
),
array(
'taxonomy' = 'resource-type',
'field' = 'slug',
'terms' = array( 'audio' ),
'operator' = 'NOT IN'
)
)
);
?
Topic multi-taxonomy-query query-posts Wordpress
Category Web