新增子比温馨提示文章页添加更新时间时效性

文章最后更新时间:2024-12-14 08:12:33

前言

子比文章页添加更新时间时效性,方便备份

演示图

图片[1]-子比温馨提示文章页添加更新时间时效性

插入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= '<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');
//文章过期提示结束

演示效果二

图片[2]-子比温馨提示文章页添加更新时间时效性

代码

[/hidecontent]
© 版权声明
THE END
喜欢就支持一下吧
赞赏
评论 共3条

请登录后发表评论