用Single主题模板2个月了,40多篇文章涉及面很广,所以Tag标签也就越来越多。但Single主题模板中的标签页内的Tag标签排序是随机的…一眼看过去就好乱。
调整Tag标签顺序的目的
通过标签排序,能体现出整个站点的文章内容大致方向,也更容易找到相关内容。所以Tag标签模板页的折腾开始了。
如何修改
在Single主题文件夹中,找到Tag标签页的模板,也可以在Typecho后台-外观设置-当前外观设置编辑器中找到Tags.php模板文件在线修改。
找到
<section class="page-content">
这下面就是Tag标签输出代码
默认是:
<?php $this -> widget('Widget_Metas_Tag_Cloud', 'sort=mid&ignoreZeroCount=1&desc=0') -> to($tags); ?>
<?php if($tags -> have()): ?>
<div class="tags-list">
<?php while ($tags -> next()): ?>
<a href="<?php $tags->permalink(); ?>" title="<?php $tags -> count(); ?> 个话题"><?php $tags -> name(); ?> (<?php $tags -> count(); ?>)</a>
<?php endwhile; ?>
<?php else: ?>
只需要修改第一行:
<?php $this -> widget('Widget_Metas_Tag_Cloud', 'sort=mid&ignoreZeroCount=1&desc=0') -> to($tags); ?>
修改为:
<?php $this->widget('Widget_Metas_Tag_Cloud', array('sort' => 'count', 'ignoreZeroCount' => true, 'desc' => true, 'limit' => 20))->to($tags); ?>
修改完成
保存之后,就可以按照Tag标签的文章归属数量进行排列输出了,赶紧试试吧。
网友评论