{
    分享网正式开通,我们为大家提供免费资源,欢迎大家踊跃投稿!

WordPress程序添加文章最后更新时间提示

将下面的函数代码加入到主题目录下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= '<div class="article-timeout"><strong><i class="fa fa-bell" aria-hidden="true"></i> 温馨提示:</strong>本文最后更新于<code>'. $updated_date . '</code>,某些文章具有时效性,若有错误或已失效,请在下方<a href="#comment">留言</a>或联系<a target="_blank" title="站长" href="http://wpa.qq.com/msgrd?v=3&uin=285541771&site=qq&menu=yes"><b>站长</b></a>。</div >';
    }
        echo $custom_content;
    }

说明:请自己修改上面有关于本站的信息,改成自己网站信息即可,图标可以用阿里矢量图。

添加以下代码到内容页模板 想要显示的位置

article_time_update();//文章过期提示

CSS代码:(在自定义CSS样式添加下面代码)

/*过期文章提示样式*/
.article-timeout{position:relative; border-radius: 8px; position: relative; margin-bottom: 25px; padding: 10px; background-color: var(--body-bg-color);}


爱资源分享网 , 版权所有丨本站资源仅限于学习研究,严禁从事商业或者非法活动!丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:WordPress程序添加文章最后更新时间提示
喜欢 ()分享 (0)