我正试着按分类法过滤帖子。
我有一个自定义的文章类型称为属性。
我有两个块,一个选择了分类"house"和"Europe",另一个选择了分类"house"和"Africa",我使用以下代码:
$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'
)
)
);
如果我按Europe和House过滤,它会显示两个区块,因为它们都有分类house。我只想显示有"Europe"和"house"的区块。
有什么想法吗?
我试过使用其他操作符,但没有一个能像我希望的那样工作。
1条答案
按热度按时间xdnvmnnf1#
你可以试试这个: