不管怎样,我只是放弃了“\\u not\\u in”方法,并采用了以下有点鬼祟祟的解决方案:
//Create the exclusion rule
$new_tax_query = array(
array(
\'taxonomy\' => \'x_category\',
\'field\' => \'slug\',
\'terms\' => array(\'y-slug\'),
\'operator\' => \'NOT IN\',
)
);
//If there is already a tax_query, \'AND\' our new rule with the entire existing rule.
$tax_query = $query->get(\'tax_query\');
if(!empty($tax_query)) {
$new_tax_query = array(
\'relation\' => \'AND\',
$tax_query,
$new_tax_query
);
}
// var_dump($new_tax_query);
$query->set(\'tax_query\', $new_tax_query);