我想要一个排除某些类别及其子类别的QueryLop,
我有这个:
$args = array(
\'category__not_in\' => array( 2, 6 ),
);
这排除了类别2和6,但没有其子类别,我能做什么?
======更新=====我就是这么做的,但现在我正在寻找更好的解决方案:
$excludes = array(2,6);
$ex_childs = array();
foreach($excludes as $exclude){
$a = get_categories(\'child_of=\'.$exclude);
foreach($a as $key => $value){
$ex_childs[] = $value->cat_ID;
}
}
$all_excludes = array_merge($excludes, $ex_childs);
$args = array(
\'category__not_in\' => $all_excludes
);