【子比美化】添加文章更新或过期失效提示

第一步,将下面的代码加入到主题目录下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="https://www.qimuyun.cn"><b>站长</b></a>。</div >';
    }
        echo $custom_content;
    }
//文章过期提示结束

第二步,在主题目录zibll/inc/functions/zib-single.php文件中,文章分页函数(代码添加处)添加下方代码即可。

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

//文章分页
    wp_link_pages(
        array(
            'before' => '<p class="text-center post-nav-links radius8 padding-6">',
            'after'  => '</p>',
        )
    );
	代码添加处
    do_action('zib_posts_content_after', $post); //添加钩子

第三步,在自定义CSS样式添加下面代码

/*过期文章提示样式*/
.article-timeout{position:relative; border-radius: 8px; position: relative; margin-bottom: 25px; padding: 10px; background-color: var(--body-bg-color);}
温馨提示:本文最后更新于2024-06-12 17:32:47,某些文章具有时效性,若有错误或已失效,请在下方留言或联系站长
------本页内容已结束,喜欢请分享------

感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容