
教程
1.将下面的函数代码加入到主题目录下functions.php文件中。
//文章过期提示
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= ' <h1 class="wp-block-zibllblock-biaoti title-theme" id="wznav_999">温馨提示:</h1> <div class="article-timeout" style="font-size:20px;"><B> 📢温馨提示:</B>本文最后更新于<code style="background-color: rgba(253,153,153,.2);">'. $updated_date . '</code>,某些文章具有时效性,若有错误或已失效,请在下方<a href="#comment" style="color:#ff3c98;">留言</a>或联系<a target="_blank" title="轻微" href="http://wpa.qq.com/msgrd?v=3&uin=123456&site=qq&menu=yes" style="color:#ff3c98;"><b>轻微</b></a>。</div >'; } echo $custom_content;}
2.调用代码:将以下代码添加到你想要显示的地方调用即可。
<?php if( article_time_update() ) : ?>
本文内容有更新
<?php endif;?>
3.在自定义CSS样式添加下面代码
/*过期文章提示样式-start*/.article-timeout{position:relative; border-radius: 8px; position: relative; margin-bottom: 25px; padding: 10px; background-color: antiquewhite;}/*过期文章提示样式-end*/
评论