WordPress中php升级到7.2“知更鸟”主题出现Warning: Use of undefined constant gallerytag – 错误

2019年12月12日18:57:48 发表评论 热度885 ℃

当WordPress中php升级到7.2版本以后,著名主题“知更鸟”会出现Warning: Use of undefinedconstant gallerytag报错
详文大致如下:
Warning: Use of undefined constant gallerytag – assumed ‘gallerytag’ (this will throw an Error in a future version ofPHP) in……
Warning: Use of undefinedconstant videotag – assumed ‘videotag’ (this will throw an Error in a future version of PHP) in……
Warning: Use of undefined constant taotag – assumed ‘taotag’ (this will throw an Error in a future version of PHP) in……

错误大致出现在169行、271行、374行。

通过翻译以上这些错误大概意思是“使用了未定义的常量gallerytag、videotag、taotag、filtersa、filtersb“

解决的办法只需要关闭”PHP错误提示“就行了,关闭错误提示有两种办法,如下:

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

WordPress中php升级到7.2“知更鸟”主题出现Warning: Use of undefined constant gallerytag – 错误

第二、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行一样的修改即可。

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

本文最后更新于:2020-03-04 10:01
瓜皮猪

发表评论

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