通用Typecho代码实现面包屑导航的效果(PHP代码实现)

有些默认的Typecho主题模板里是没有面包屑导航的,这个对于SEO效果不够好,这里老蒋整理到一个常用的PHP代码实现的通用Typecho面包屑导航,整理收藏,如果有需要可以使用。

具体代码如下:

<div class="breadcrumb">
<?php if($this->is('index')):?><!-- 页面首页时 -->
<a href="<?php $this->options->siteUrl(); ?>" title="<?php $this->options->title(); ?>">首页</a> &gt;
<?php elseif ($this->is('post')): ?><!-- 页面为文章单页时 -->
<a href="<?php $this->options->siteUrl(); ?>" title="<?php $this->options->title(); ?>">首页</a> &gt; <?php $this->category(); ?> &gt; <?php $this->title(); ?>
<?php else: ?><!-- 页面为其他页时 -->
<a href="<?php $this->options->siteUrl(); ?>" title="<?php $this->options->title(); ?>">首页</a> &gt; <?php $this->archiveTitle(' &raquo; ','',''); ?>
<?php endif; ?>
</div>

完成代码撰写后,我们把他们添加到需要显示面包屑位置对应的模板文件中即可,如header.php。

投上你的一票

原创文章,转载请注明出处:https://www.itbulu.com/typecho-seotitle.html

上一篇 2022年1月17日 09:58
下一篇 2022年1月18日 11:13

相关推荐

  • Typecho自定义面包屑导航调用方法

    有些Typecho主题中是没有自带面包屑导航的,那我们就需要自己来定义。尤其是在页面比较多的时候需要用到面包屑导航,要不用户访问页面之后无法进入其他页面。在这篇文章中,老蒋整理到T…

    2018年11月26日