目前有3级分类:
家电,冰箱,智能冰箱
家电,冰箱,节能冰箱
家电,电视,智能电视
家电,空调,智能空调
现在我使用以下代码可以调取出当前分类的所有子分类
家电:冰箱,智能冰箱,节能冰箱,空调,智能空调,电视,智能电视
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号
}
<?php
if(get_query_var("cat"))
{
echo '<ul class="soncategory">';
echo '<li class="categorytext">分类:</li>';
echo wp_list_categories("child_of=" . get_query_var("cat") . "&depth=0&hide_empty=0&title_li=&orderby=id&order=ASC");
echo '</ul>';
}?>
哪里出问题了,我只想调用当前分类的子分类,如
家电:电视,空调,冰箱
冰箱:节能冰箱,智能冰箱
要如何实现
好吧,解决了