最近这两个月网站收录大幅度下降,各大搜索引擎搜索结果报错,仔细一看,是『description』文章描述报错。
报错内容为:Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/post-template.php on line 284
后台查询是wordpress根目录/wp-includes/post-template.php的第284行报错。
一番谷歌后,发现是wordpress对php7.2的兼容性问题,找到了解决办法
复制下面内容并进行替换保存既可解决问题:
if ( is_array( $pages ) ) {
if ( $page > count( $pages ) ) // if the requested page doesn't exist
$page = count( $pages ); // give them the highest numbered page that DOES exist
} else {
$page = 0;
}
江眠
2018-12-22 20:38:26感谢,问下如果wordpress更新了文件需要重新改吗
熙慧来琳
2018-12-23 15:45:17@江眠 我还没更新,如果更新依旧出错就改吧
nice
2018-12-13 17:43:02感谢大佬解决我遇到的问题 :cowboy:
可爱的匿名访客
2018-11-13 11:08:23😛
王 木 木🍉 🍉
2018-10-17 11:29:15原来是这样