Typecho获取当前父分类的所有子分类

代码如下:

<?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
<?php while ($categorys->next()): ?>
<?php
if  ($this->category == $categorys->slug&&($this->is("post")||$this->is("category"))){
$childrens = $this->widget('Widget_Metas_Category_List')->getAllChildren($categorys->parent);
for ($i=0; $i <count($childrens) ; $i++) { 
$thisChild = $this->widget('Widget_Metas_Category_List')->getCategory($childrens[$i]);
?>
<li><a href="<?php echo $thisChild["permalink"] ?>"><?php echo $thisChild["name"] ?></a></li>
<?php
}
}
?>
<?php endwhile;?>

输出如下:

<li>
    <a href="https://www.joker.cc/category/child1/">子分类1</a>
</li>
<li>
    <a href="https://www.joker.cc/category/child2/">子分类2</a>
</li>
<li>
    <a href="https://www.joker.cc/category/child3/">子分类3</a>
</li>

Joker ·
评论 · 首页 订阅