我没有运行这段代码,因此可能会出现语法错误,但要点是返回具有指定特征类别的术语的userfeed分类法,或返回具有指定和特征类别的术语的cities分类法或任何其他非这些分类法。有点笨重,也许有更好的方法:
$query->set( \'tax_query\', array(
\'relation\' => \'OR\',
array(
array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'userfeed-taxonomy\',
\'field\' => \'id\',
\'terms\' => $terms1
),
array(
\'taxonomy\' => \'category\',
\'field\' => \'slug\',
\'terms\' => array( \'featured\' )
),
),
),
array(
array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'cities-taxonomy\',
\'field\' => \'id\',
\'terms\' => $terms2
),
array(
\'taxonomy\' => \'category\',
\'field\' => \'slug\',
\'terms\' => array( \'featured\' )
),
),
),
array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'userfeed-taxonomy\',
\'field\' => \'id\',
\'terms\' => $terms1,
\'operator\' => \'NOT IN\'
),
array(
\'taxonomy\' => \'cities-taxonomy\',
\'field\' => \'id\',
\'terms\' => $terms2,
\'operator\' => \'NOT IN\'
)
)
) );