I want to show posts which are filed 2 or more custom taxonomy terms. For example, I want to show the posts from custom post type “Classified” and filed under Books and House terms.
The code below show posts which are marked in either of the terms. I want only the posts marked in both the terms:
$args = array(
'posts_per_page' => 10, // Number of posts per page
'post_type' => 'classifieds', // Custom Post Type like Movies
'tax_query' => array(
array(
'taxonomy' => 'classifieds_tags', //Custom Taxonomy Name like Genre
'field' => 'slug',
'terms' => array(
'books', //Tags or Categories like Drama or Comedy
'houses'
)
)
)
);
You need to combine two tax queries with and
AND
relation:I think you need to add the
relation
argument :