今天分享大家的时WordPress在文章底部添加更新或过期失效提示,让阅读者更好清楚文章和资源的具体时间,一个比较实用的小美化,喜欢的朋友可以收藏。
效果图:
教程
1、将下面的函数代码加入到主题目录下functions.php文件中。
//文章过期提示 by soujiz.com
function article_time_update() {
date_default_timezone_set('PRC');
$newdate=time();
$updated_date = get_the_modified_time('Y-m-d H:i:s');
$updatetime=strtotime($updated_date);
$custom_content = '';
if ( $newdate > $updatetime+86400) {
$custom_content= '<div class="article-timeout"><strong><i class="fa fa-bell" aria-hidden="true"></i> 温馨提示:</strong>本文最后更新于<code>'. $updated_date . '</code>,某些文章具有时效性,若有错误或已失效,请在下方<a href="#comment">留言</a></div >';
}
echo $custom_content;
}
2、在子比主题目录zibll/inc/functions/zib-single.php文件中,文章分页函数(子比主题V5.5版本(主题更新有可能会有变动)在320行,回车换行,然后将代码放在321行,见下图)下面添加下方代码即可。
article_time_update();//文章过期提示
提示:可以按照下面本站下面图中的一个长关键词搜索查找到位置,
3、CSS代码:(在后台主题的自定义CSS样式添加下面代码)
/*过期文章提示样式*/ .article-timeout{position:relative; border-radius: 8px; position: relative; margin-bottom: 25px; padding: 10px; background-color: var(--body-bg-color);}
温馨提示:本文最后更新于
2023-07-29 15:28:27
,某些文章具有时效性,若有错误或已失效,请在下方留言© 版权声明
THE END
暂无评论内容