问题
Is there a way to get all sub categories of several categories? something like:
get_categories( array( 'child_of'=>array(10,3,8) );
回答1:
It's not possible, wordpress just accepts one integer in all it's functions that get categories children. You'll have to get their children separately:
$terms = array();
$taxonomy = 'category';
$parents = array(10, 3, 8);
foreach ($parents as $parent) {
$terms = array_merge($terms, get_categories(array('child_of'=> $parent)));
}
foreach ($terms as $term) {
// your code here
}
Hope it helps!
来源:https://stackoverflow.com/questions/35825561/get-sub-categories-of-several-categories-with-get-categories