好吧,我又来凑收录了[aru_17]
主题不同,添加的位置也不同,找找 index.php 和 single.php 文件中的 section 或者 article 标签,在标签附近将以下代码添加到 the_title();
附近
比如我的主题位置
代码:
/* 首页置顶 */
<?php if ( is_sticky() ) { echo '<span title="首页置顶" class="article-ontop">置顶</span> · ';}?>
/* 最新文章 */
<?php
date_default_timezone_set('PRC');
$t1=$post->post_date;
$t2=date("Y-m-d H:i:s");
$diff=(strtotime($t2)-strtotime($t1))/3600;
if($diff<24){echo '<span title="最新文章" class="article-ontop">最新</span> · ';} // new.gif 替换成你的图片
?>
我用的文字,如果需要图标的话,修改 echo ''
中的内容即可
WordPress 添加首页文章最新和置顶图标,方法其实就是这么简单~