宝塔面板wordpress“知更鸟”主题升级到php7.2,出现Warning: Use of undefined constant taotag – assumed ‘taotag’ (this will throw an Error in a future version of PHP) 解决办法!

  • A+
所属分类:电脑技巧

宝塔面板wordpress“知更鸟”主题升级到php7.2,出现Warning: Use of undefined constant taotag – assumed ‘taotag’ (this will throw an Error in a future version of PHP) 解决办法!

最近,华哥将网站运行的硬件进行了升级,从虚拟主机换成了vps,同时,用上最新的宝塔面板(基于centos7的6.9版本),php主要是用7.2版本,网上资料说,wordpress完美支持php7.0及以上版本,那么现阶段选择php7.2是可以承前启后的。

附华哥为什么要选择php7,因为快;为什么选择php7.2,因为其稳定。

一通wordpress搬家操作。域名解析更换且成功后,浏览网站,出现这么一大串:

constant gallerytag – assumed ‘gallerytag’ (this will throw an Error in a future version of PHPin……

constant videotag – assumed ‘videotag’ (this will throw an Error in a future version of PHP) in……

constant taotag – assumed ‘taotag’ (this will throw an Error in a future version of PHP) in……

constant filtersa – assumed ‘filtersa’ (this will throw an Error in a future version of PHP) in constant filtersb – assumed ‘filtersb’ (this will throw an Error in a future version of PHP) in……

……好多好多,不忍描述。然后下面是网站正常的样子。

以上这些错误大概意思是“使用了未定义的常量gallerytag、videotag、taotag、filtersa、filtersb,这将在未来的PHP版本中引发错误“;

我去,不是说wordpress完美支持php7么?怎么会这样,细一思考,这其实不怪wordpress,而是用的是“知更鸟”主题,这个主题有很多字段模型,如上面的gallerytag、videotag等,这都是主题附带的。

那解决方法有两种:

一、升级主题,这个不太现实。

二、只是报了”Warning警告“,我能不能不让这些错误信息显示?

看来只需要关闭”PHP错误提示“就行了。宝塔面板中操作如下:

进入php管理,点“配置修改”,设置display_errors为关闭,然后保存,重启一下服务。

宝塔面板wordpress“知更鸟”主题升级到php7.2,出现Warning: Use of undefined constant taotag – assumed ‘taotag’ (this will throw an Error in a future version of PHP) 解决办法!

就这么简单。

如果不是在宝塔面板,那就要深入腹地,修改php.ini文件。

1、打开 php.ini

2、设置 error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

3、设置 display_errors = Off

其实两个方法,只是方式不同,改的都是同一个东西。

 

不过博主使用的是另外一种办法,找到出现错误的位置post-taxonomy.php

修改前

  1. 'rewrite' => array( 'slug' => gallerytag ),

修改后

  1. 'rewrite' => array( 'slug' => 'gallerytag' ),

貌似没有什么改动,仔细看的话会发现只是用单引号把gallerytag括起来而已,那么同理也只需要把271行、374行一样的修改即可。

修改完成后保存,然后刷新页面,问题完美解决。

 

学习资料见知识星球。

以上就是今天要分享的技巧,你学会了吗?若有什么问题,欢迎在下方留言。

快来试试吧,小琥 my21ke007。获取 1000个免费 Excel模板福利​​​​!

更多技巧, www.excelbook.cn

欢迎 加入 零售创新 知识星球,知识星球主要以数据分析、报告分享、数据工具讨论为主;

宝塔面板wordpress“知更鸟”主题升级到php7.2,出现Warning: Use of undefined constant taotag – assumed ‘taotag’ (this will throw an Error in a future version of PHP) 解决办法!

你将获得:

1、价值上万元的专业的PPT报告模板。

2、专业案例分析和解读笔记。

3、实用的Excel、Word、PPT技巧。

4、VIP讨论群,共享资源。

5、优惠的会员商品。

6、一次付费只需99元,即可下载本站文章涉及的文件和软件。

  • 我的微信
  • weinxin
  • 我的知识星球
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: