最新消息:

网站报错count(): Parameter must be an array or an object的解决方法

建站交流 86浏览 0评论

WordPress的网站如果采用php7,那么评论位置就会出现一个报错警告,类似Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/oswhy.com/wp-includes/class-wp-comment-query.php on line 399

这个报错是php7版本引起的,当传递一个无效参数的时候,count()函数会抛出warning的警告,更新到php8.2版本即可解决,如果不想更新php版本,那么可以修改网站对应文件,提示count()参数必须是一个数组或一个对象,所以方法就是直接将它设为数组。

$this->comment_count = count( $this->comments );

修改为

$this->comment_count = count((array) $this->comments );

转载请注明:系统之家官网 » 网站报错count(): Parameter must be an array or an object的解决方法

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址