Typecho导航菜单显示分类的解决方法

服务器 · 2021-04-02

将Typecho分类添加到导航菜单的方法很简单,只需要编辑header.php文件,将分类代码添加到header.php模板文件中即可,代码如下:

<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while ($category->next()): ?>
<a<?php if ($this->is('post')): ?>
<?php if ($this->category == $category->slug): ?> class="current"<?php endif; ?>
<?php else: ?>
<?php if ($this->is('category', $category->slug)): ?> class="current"<?php endif; ?>
<?php endif; ?> href="<?php $category->permalink(); ?>"><?php $category->name(); ?></a>
<?php endwhile; ?>

登录到Typecho后台--控制台--外观--编辑文件header.php,复制以上代码,粘贴到下图中的位置:

然后点保存文件即可

Theme Jasmine by Kent Liao