打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
typecho导航栏调用分类目录

typecho的默认主题导航菜单部分调用的是独立页面,而我们搭建网站一般是把分类目录显示在导航栏,或者把分类目录和独立页面一起显示在导航栏,这样便于访客浏览网站目录。下面博客吧分享typecho分类目录显示在导航栏的代码。

只显示分类目录

在主题的header.php文件中找到代码:

1234
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?><?php while($pages->next()): ?><a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a><?php endwhile; ?>

修改为以下代码:

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

分类目录和独立页面都显示

在主题的header.php文件中找到代码:

1234
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?><?php while($pages->next()): ?><a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a><?php endwhile; ?>

在该代码上面添加代码:

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



本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
wordpress指定文章列表后添加广告
如何使WordPress博客添加多个sidebar侧边栏
站外以HTML的形式调用wordpress文章
WordPress 让主题支持Widget(侧边栏小工具)功能
程序
PHP中冒号、endif、endwhile、endfor这些都是什么
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服