1.将此函数放在你模版的函数中
function get_category_root_id($cat){
$this_category = get_category($cat); // 取得当前分类
while($this_category->category_parent){ // 若当前分类有上级分类时,循环
$this_category = get_category($this_category->category_parent); // 将当前分类设为上级分类(往上爬)
}
return $this_category->term_id; // 返回根分类的id号
}
2.页面调用
<?php
wp_list_categories("child_of=".get_category_root_id(the_category_ID(false))."&depth=0&hide_empty=0&title_li=");
?>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)