大佬教程收集整理的这篇文章主要介绍了WordPress教程:超过一定时间的老文章顶部显示自定义信息,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
站长朋友们在wordpress插件库查找插件时,偶尔会看到提示说插件已经超过 2 年没有更新。如果我们想在自己的wordpress老文章顶部显示类似的提示信息,比如超过 1 年没有更新的文章,就提示某些信息,如下图所示:
这篇wordpress教程里,我们就向大家介绍一下实现的方法。切换到主题目录,打开 functions.PHP 文件,加入以下代码:
Crayon-nums " data-settings="show"> Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"> Crayon-num" data-line="Crayon-5c891cbd7fca2229907978-1">1 Crayon-num" data-line="Crayon-5c891cbd7fca2229907978-3">3 Crayon-num" data-line="Crayon-5c891cbd7fca2229907978-5">5 Crayon-num" data-line="Crayon-5c891cbd7fca2229907978-7">7 Crayon-num" data-line="Crayon-5c891cbd7fca2229907978-9">9 Crayon-num" data-line="Crayon-5c891cbd7fca2229907978-11">11 | Crayon-code"> Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"> Crayon-line Crayon-striped-line" id="Crayon-5c891cbd7fca2229907978-2">Crayon-t">functionCrayon-h"> Crayon-e">old_content_messageCrayon-sy">(Crayon-v">$contentCrayon-sy">)Crayon-h"> Crayon-sy">{ Crayon-line" id="Crayon-5c891cbd7fca2229907978-3">Crayon-h"> Crayon-v">$modifiedCrayon-h"> Crayon-o">=Crayon-h"> Crayon-e">get_the_modified_timeCrayon-sy">(Crayon-s">'U'Crayon-sy">)Crayon-sy">;Crayon-h"> Crayon-line Crayon-striped-line" id="Crayon-5c891cbd7fca2229907978-4">Crayon-h"> Crayon-v">$currentCrayon-h"> Crayon-o">=Crayon-h"> Crayon-e">current_timeCrayon-sy">(Crayon-s">'timestamp'Crayon-sy">)Crayon-sy">; Crayon-line" id="Crayon-5c891cbd7fca2229907978-5">Crayon-h"> Crayon-v">$diffTimeCrayon-h"> Crayon-o">=Crayon-h"> Crayon-sy">(Crayon-v">$currentCrayon-h"> Crayon-o">-Crayon-h"> Crayon-v">$modifiedCrayon-sy">)Crayon-h"> Crayon-o">/Crayon-h"> Crayon-sy">(Crayon-cn">60Crayon-o">*Crayon-cn">60Crayon-o">*Crayon-cn">24Crayon-sy">)Crayon-sy">;Crayon-h"> Crayon-line Crayon-striped-line" id="Crayon-5c891cbd7fca2229907978-6">Crayon-h"> Crayon-st">ifCrayon-sy">(Crayon-v">$diffTimeCrayon-h"> Crayon-h"> Crayon-cn">365Crayon-h"> Crayon-sy">)Crayon-sy">{ Crayon-line" id="Crayon-5c891cbd7fca2229907978-7">Crayon-h"> Crayon-v">$contentCrayon-h"> Crayon-o">=Crayon-h"> Crayon-s">'Crayon-sy">.Crayon-e">get_the_modified_timeCrayon-sy">(Crayon-s">'Y年n月j日'Crayon-sy">)Crayon-sy">.Crayon-s">',已超过 1 年没有更新,如果文章内容失效,请反馈给我们,谢谢! 'Crayon-sy">.Crayon-v">$contentCrayon-sy">;Crayon-line" id="Crayon-5c891cbd7fca2229907978-9">Crayon-h"> Crayon-k ">returnCrayon-h"> Crayon-v">$contentCrayon-sy">; Crayon-line" id="Crayon-5c891cbd7fca2229907978-11">Crayon-e">add_filterCrayon-sy">(Crayon-h"> Crayon-s">'the_content'Crayon-sy">,Crayon-h"> Crayon-s">'old_content_message'Crayon-h"> Crayon-sy">)Crayon-sy">; |
以上是大佬教程为你收集整理的WordPress教程:超过一定时间的老文章顶部显示自定义信息全部内容,希望文章能够帮你解决WordPress教程:超过一定时间的老文章顶部显示自定义信息所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。