【问题标题】:WordPress, get_categories, taxonomyWordPress,get_categories,分类
【发布时间】:2011-11-04 10:32:18
【问题描述】:

我有一个非常简单的问题,WordPress Codex 没有回答。

get_categories() 函数获取分类的选项。我想问的是,我可以通过多个这样的分类吗:

get_categories(
    array(
        'taxonomies' => 'category,my_custom_taxonomy'
    )
);

【问题讨论】:

    标签: wordpress taxonomy


    【解决方案1】:

    get_categories 函数只允许为分类 arg 输入字符串(1 个分类)。

    您可以使用get_terms,它允许分类法数组。

    $args = array( 'taxonomies' => array( 'tax_1', 'tax_2', 'tax_3') );
    
    $categories = get_terms ( $args );
    
    for each ( $categories as $cat ) :
    
      var_dump( $cat );
    
    endforeach;
    

    【讨论】:

    • 非常感谢克里斯!我只是忘记了函数 get_terms() ! xaxax :D 再次非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2010-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多