Typecho导航菜单默认显示首页和关于等独立页面,Typecho后台创建的分类不会自动添加到导航菜单中,新手站长网分享将分类栏目添加到导航菜单中的方法:

Typecho分类添加到导航菜单的方法

将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,复制以上代码,粘贴到下图中的位置:

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

typecho导航菜单添加分类

然后点保存文件即可。

标签: none