最新公告
  • 欢迎您光临知事网软件APP资源下载站,一个优质的手机App应用商店和网站源码基地。欢迎加入永久SVIP
  • WordPress函数get_all_category_ids()用法 获取博客所有分类id集合

    正文概述 知事网   2020-09-11 11:09:04   345

    描述:

    获取博客所有的分类id集合

    用法:

    <?php get_all_category_ids() ?>

    参数:

    None

    示例:

    <?php
    $category_ids = get_all_category_ids();
    foreach($category_ids as $cat_id) {
    $cat_name = get_cat_name($cat_id);
    echo $cat_id . ': ' . $cat_name;
    }
    ?>

    源文件:

    function get_all_category_ids() {
    _deprecated_function( __FUNCTION__, '4.0.0', 'get_terms()' );
    
    if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
    $cat_ids = get_terms(
    array(
    'taxonomy' => 'category',
    'fields' => 'ids',
    'get' => 'all',
    )
    );
    wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
    }
    
    return $cat_ids;
    }

    知事网 » WordPress函数get_all_category_ids()用法 获取博客所有分类id集合

    发表评论

    还没有评论,快来抢沙发吧!

    [!--temp.right--]
    请选择支付方式
    ×
    余额支付
    ×
    微信扫码支付 0 元