子比主题文章结尾添加最后更新时间或过期失效提示

------正文内容展示,开始汲取新知识啦------

如图:

子比主题文章结尾添加最后更新时间或过期失效提示

教程开始:

1.将下面的 PHP 代码加入到主题目录下:themes/zibll/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" rel="external nofollow" >留言</a>或联系<a target="_blank" title="天亦资源网" href="http://wpa.qq.com/msgrd?v=3&uin=1234567&site=qq&menu=yes" rel="external nofollow" ><b>天亦资源网</b></a>。</div >';
    }
        echo $custom_content;
    }
//文章过期提示结束

2.在主题目录themes/zibll/inc/functions/zib-single.php 文件中,文章分页函数(我的是在 317 行,因为我的代码有改动,所有不确定行数,见下图)搜索文章分页或者添加钩子,下面添加下方代码即可。

PHP代码

article_time_update();//文章过期提示
子比主题文章结尾添加最后更新时间或过期失效提示

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

温馨提示:本文最后更新于2024-04-28 17:38:22已超过66天没有更新,某些文章具有时效性,若有错误或已失效,请在下方留言或联系官方客服
© 版权声明
CATXE.COM
喜欢就支持一下吧
点赞13赞赏 分享打赏
评论 抢沙发

请登录后发表评论

    暂无评论内容