I'm trying to filter posts by their taxonomy.
I've a custom post type called Properties.
I have two blocks one with the taxonomies "house" and "Europe" selected and another one with the taxonomies "house" and "Africa" selected I'm using the following code:
$args = array(
'post_type' => 'property',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'location',
'field' => 'slug',
'terms' => array('europe','house'),
'operator' => 'IN'
),
),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'guests',
'value' => $guests,
'compare' => 'LIKE'
),
array(
'key' => 'beds',
'value' => $beds,
'compare' => 'LIKE'
),
array(
'key' => 'baths',
'value' => $baths,
'compare' => 'LIKE'
)
)
);
If I filter by Europe and House it's displaying both blocks because both have the taxonomy house. I'd like to show only the one with "Europe" and "house" ones.
Any ideas?
I've tried using other operators but none of them are working as I'd like.
Solved! I've done it in the following way: