Typecho输出分类列表

Typecho输出分类列表

2023年08月09日 作者头像 作者头像 泽泽社长 编辑

评论

0 Count

输出所有分类列表,一般用于显示在菜单上

<?php \Widget\Metas\Category\Rows::alloc()->to($cates); ?>
<?php while ($cates->next()): ?>
   <a href="<?php $cates->permalink(); ?>" <?php if($this->is('category', $cates->slug)): ?>class="text-blue"<?php endif; ?>><?php $cates->name(); ?>(<?php $cates->count(); ?>)</a>
<?php endwhile; ?>

<?php if($this->is('category', $cates->slug)): ?>class="text-blue"<?php endif; ?>是判断当前页面缩略名是否等于分类列表中的某个分类,等于则对超链接追加独立的class使其样式与其他作为区别。

$cates->count为分类中文章数量。