文章底部添加最后更新时间或过期失效提示

凌貓博客提供第一手优质资源。更新快、质量高、内容多,这是你的不二选择!我们只更新优质纯净资源,相信你会喜欢这里,也欢迎前来投稿入驻

1.将下面的 PHP 代码加入到主题目录下:themes/zibll/functions.php 文件中。

//文章过期提示开始
// BY:凌貓博客
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=3064305626&site=qq&menu=yes"><b>凌貓</b></a>。</div >';
    }
        echo $custom_content;
    }
// BY:凌貓博客
//文章过期提示结束

2.在主题目录themes/zibll/inc/functions/zib-single.php 文件中,文章分页函数(见下图)下面添加下方代码即可。

图片[1]-文章底部添加最后更新时间或过期失效提示-凌貓博客
article_time_update();//文章过期提示

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

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

-----本页内容已结束,喜欢请分享-----
© 版权声明
THE END
喜欢就投喂一下吧
点赞0投喂 分享
相关推荐
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容