使用的 XIU 主题首页文章是根据更新时间来排序,需要有醒目的 NEW 图标来辨识最新发布文章,24小时后自动取消。
大前端的 XIU 主题和DUX主题,需要修改 excerpt.php 文件,找到该段代码
echo‘<h2><a’._post_target_blank().’ href=”‘.get_permalink().'” title=”‘.get_the_title().get_the_subtitle(false)._get_delimiter().get_bloginfo(‘name’).'”>’.get_the_title().get_the_subtitle().'</a></h2>
在后面添加以下代码即可。
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 "<img src='https://imgs.wiki/imgs/2020/09/40153b613a45c4c9.gif' />";} // gif地址不需要修改,该图片在IMGS图床 else{echo "";} //时间超过时候显示空白
主题更新后,该代码需要重新添加。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持以下吧