最近升级了php到7.2版本了,但是出现了个别页面有报错
Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/wp-includes/post-template.php on line 293

查看加百度后发现php7.2版本更新当传递一个无效参数的时候,count()函数会抛出warning的警告
也就是不要传递无效的参数,需要加判断

最终解决就是把count数组定义为0解决,wordpress官方还未更新,只能自己手动改下post-template.php

NOTE:将原来约293行的代码
if ( $page > count( $pages ) ) { // if the requested page doesn't exist
		$page = count( $pages ); // give them the highest numbered page that DOES exist
	}
NOTE:修改为
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;
}