求助:怎么让wordpress只调用某个分类的网址?

dami (UID: 4460) 1月前

473 2

想学大佬搞个米表联盟,创建了一个米表联盟页面,然后用下面代码调用网址模块,发现把首页的所有网址都调用了。请问怎么设置可以只调用某个分类?比如“米表联盟”!

    // 加载网址模块
    foreach($categories as $category) {
        if($category->category_parent == 0){
            $children = get_categories(array(
                'taxonomy'   => 'favorites',
                'meta_key'   => '_term_order',
                'orderby'    => 'meta_value_num',
                'order'      => 'desc',
                'child_of'   => $category->term_id,
                'hide_empty' => 0
            ));
            if(empty($children)){ 
                fav_con($category);
            }else{
                if(io_get_option("tab_type")) {
                    fav_con_tab($children,$category->term_id);
                }else{
                    foreach($children as $mid) {
                        fav_con($mid);
                    }
                }
            }
        }
    } 

 

www.dami.pub
已有评论 (2)
  • 头像
    dami (UID: 4460) @Ta
    1月前 (www.dami.pub)
    1
    amdyyds 不用循环,直接根据slug或id获取分类就行

    谢谢

  • 头像
    dami (UID: 4460) @Ta
    1月前 (www.dami.pub)
    2
    王某 <?php $args=array( 'orderby' => 'id', 'cat' => $CID, // 分类ID ...

    多谢解答

    • 大佬论坛
      3
      登录后才可回帖  登录 注册

本站同款香港KC服务器 酷盾安全联盟 智能优化防护 ROOVPS 便宜服务器 盾云SCDN 月付只需1元起 运营商直营授权 大流量卡