【问题标题】:get sub categories of several categories with get_categories()使用 get_categories() 获取多个类别的子类别
【发布时间】:2016-03-06 10:09:02
【问题描述】:

有没有办法获得几个类别的所有子类别?类似:

get_categories( array( 'child_of'=>array(10,3,8) );

【问题讨论】:

  • 我的梦想是知道为什么人们有时会不投票。

标签: wordpress categories


【解决方案1】:

这是不可能的,wordpress 在所有获取子类别的函数中只接受一个整数。您必须单独让他们的孩子:

$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
}

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    • 2015-10-09
    • 2015-08-14
    • 1970-01-01
    • 2023-03-17
    • 2018-11-28
    相关资源
    最近更新 更多