我用这个代码来排除一个类别,但它仍然显示展览中的所有帖子。
$posts = get_posts(array(
\'post_type\' => \'exhibition\',
\'taxonomy\' => \'categories_for_exhibitions\',
\'field\' => \'slug\',
\'terms\' => array(\'current\'),
\'operator\' => \'NOT IN\',
));
SO网友:Muhammad Adnan Bashir
找到了答案,可以让其他人受益
$posts = get_posts(array(
\'post_type\' => \'exhibition\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'categories_for_exhibitions\',
\'field\' => \'slug\',
\'terms\' => \'current\',
operator => \'NOT IN\',
),
)
));