子比主题-添加文章更新或过期提醒

效果预览

查看本站任意文章详情

美化步骤

主要分为三个步骤:

  1. zibll主题functions.php文件中添加函数
  2. zibll主题分页函数前添加上面函数
  3. zibll主题后台添加自定义css

添加函数

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">留言</a>或联系<a
            target="_blank" title="轩逸博客" href="http://wpa.qq.com/msgrd?v=3&uin=1649825180&site=qq&menu=yes"><b>轩逸站长</b></a>。
    </div>';
    }
    echo $custom_content;
}

函数调用

编辑zibll/inc/functions/zib-single.php文件

将以下代码添加到如下位置,子比版本7.4.5大概:315行

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

图片[1]-子比主题-添加文章更新或过期提醒

自定义css

主题设置 -> 全局&功能 -> 自定义代码

将以下css代码,复制到自定义CSS样式中即可


/*过期文章提示样式*/
.article-timeout {
    position: relative;
    border-radius: 8px;
    position: relative;
    margin-bottom: 25px;
    padding: 10px;
    background-color: var(--body-bg-color);
}
``
- - - - - 本页内容已结束,喜欢请分享 - - - - -

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

© 版权声明
THE END
喜欢就支持一下吧
点赞370 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容