WordPress文章失效提醒

图片[1]-WordPress文章失效提醒-泽楠云资源博客

教程

修改functions.php文件

将下面的函数代码加入到主题目录下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= '    <h1 class="wp-block-zibllblock-biaoti title-theme" id="wznav_999">温馨提示:</h1>    <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=905730354&site=qq&menu=yes"><b>关泽楠</b></a>。</div >';    }        echo $custom_content;}

修改zib-single.php文件

在主题目录zibll/inc/functions/zib-single.php文件中,文章分页函数(大概是323行,因为我的代码有改动,所有不确定行数,见下图)下面添加下方代码即可。

添加这个方法:

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

如下:

图片[2]-WordPress文章失效提醒-泽楠云资源博客

修改CSS样式

在自定义CSS样式添加下面代码

/*过期文章提示样式-start*/.article-timeout{position:relative; border-radius: 8px; position: relative; margin-bottom: 25px; padding: 10px; background-color: antiquewhite;}/*过期文章提示样式-end*/
© 版权声明
THE END
喜欢就支持一下吧
点赞9赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容