顶部最后更新时间或过期失效提示子比主题美化

温馨提示: 本文最后更新于 2025-09-21 21:47:34 ,部分文章具有时效性, 若有错误或已失效,请在下方留言!

为了在文章页面顶部显示最后更新时间或过期失效提示,你可以将以下代码添加到主题目录下的 functions.php 或新建一个 func.php

//在functions.php或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 {
        margin-bottom: 20px;
        background-color: var(--body-bg-color);
        border-radius: 10px;
        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
喜欢就支持一下吧
点赞8 分享
评论 共1条

请登录后发表评论