抱歉耽搁了大家,我不在城里!这是我今天发现并使用的。我必须检查选择了一个分类法而没有选择一个分类法的情况,这实际上只需要一个简单的税务查询,但这给了我空值并破坏了查询,因此我不得不使用一些条件来构建它。
$TypeID和$UnionSID是所选分类的数组。
谢谢你的建议!
//Set the proper tax_query based on what we\'re looking for
if ($typeIDs && $unionIDs) {
$args[\'tax_query\'] = array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'audition_type\',
\'field\' => \'term_id\',
\'terms\' => $typeIDs,
),
array(
\'taxonomy\' => \'union_requirement\',
\'field\' => \'term_id\',
\'terms\' => $unionIDs,
\'operator\' => \'AND\'
)
);
} elseif ($typeIDs) {
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'audition_type\',
\'field\' => \'term_id\',
\'terms\' => $typeIDs,
)
);
} else if ($unionIDs) {
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'union_requirement\',
\'field\' => \'term_id\',
\'terms\' => $unionIDs,
)
);
} else {
$args[\'tax_query\'] = false;
}