虽然这样做有效:
$query->set( \'post__not_in\', array( 30140, 30020, 30008, 29998, 29991, 21458, 20197, 11986, 6614 ) );
这不会:
$tax_query = array(
\'taxonomy\' => \'filter\',
\'terms\' => array(30140, 30020, 30008, 29998, 29991, 21458,20197,11986,6614),
\'field\' => \'term_id\',
\'operator\' => \'NOT IN\');
$query->set( \'tax_query\', $tax_query );
SO网友:Krzysiek Dróżdż
代码的主要问题是tax_query
应该是查询数组,而不是单个查询。
$tax_query = array(
array(
\'taxonomy\' => \'filter\',
\'terms\' => array(30140, 30020, 30008, 29998, 29991, 21458,20197,11986,6614),
\'field\' => \'term_id\',
\'operator\' => \'NOT IN\'
)
);
$query->set( \'tax_query\', $tax_query );