WordPress给今日文章添加new标记

2010年02月12日03:32:57 1 热度2,385 ℃

 在很多网站上都会看到最新消息的标题后有一个new的图标(类似上图效果),就这么一个小图标,却能引起读者更多的注意力. 刚在seri小朋友这看到了一个不错的方法,可以给wordpress 24小时以内的文章标题处添加new标记.1.在主题index.php中找到<?php the_title(); ?> ,在 后面加上

<?php $t1=$post->post_date; $t2=date("Y-m-d H:i:s"); $diff=(strtotime($t2)-strtotime($t1))/3600;
if($diff<24){echo "<img src='https://www.guapizhu.com/3445000124_d3a002480a_t.jpg' alt=''>";} ?>

本文最后更新于:2018-12-03 16:54
瓜皮猪

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:1   其中:访客  0   博主  0

    • 无冷 无冷 0

      不错的方法