给子比文章页添加更新时间时效性

给子比文章页添加更新时间时效性

效果图

屏幕截图 2024-10-09 012402

zibll/func.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= '<style>.article-timeout{    color: #8a6d3b;
    border-color: #faebcc;margin-bottom:20px;
    background-color: #fcf8e3;border-radius:8px;padding:10px 10px;}</style><div class="article-timeout"><strong><i class="fa fa-bell" aria-hidden="true"></i> 温馨提示:</strong>本文最后更新于<code>'. $updated_date . '</code>,某些文章具有时效性,若有错误或已失效,请在下方留言。</div >';
    }
        echo $custom_content;
    }
    add_action('zib_posts_content_before','article_time_update');
//文章过期提示结束

 

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

昵称

取消
昵称表情代码图片

    暂无评论内容