wp head - "Warning: count()" printing in Page templates

I recently made a local copy of an existing site to make development changes. Most everything is working fine in the loc

I recently made a local copy of an existing site to make development changes. Most everything is working fine in the local version, except that at the top of any Page I see this error (sometimes more than once) –

Warning: count(): Parameter must be an array or an object that implements Countable in /[website directory]/wp-includes/post-template.php on line 284

It looks like <?php wp_head(); ?> is throwing the error when php checks to see if the selected post has more than one page, and that it's the $pages variable that's failing. I've tried manually setting $pages to an empty array before that, but that didn't make any difference.

The only other thing I can think of is that my dev environment is running php 7.2 but the production server (which is working fine) is running 5.6. Might that have anything to do with this issue?

I recently made a local copy of an existing site to make development changes. Most everything is working fine in the local version, except that at the top of any Page I see this error (sometimes more than once) –

Warning: count(): Parameter must be an array or an object that implements Countable in /[website directory]/wp-includes/post-template.php on line 284

It looks like <?php wp_head(); ?> is throwing the error when php checks to see if the selected post has more than one page, and that it's the $pages variable that's failing. I've tried manually setting $pages to an empty array before that, but that didn't make any difference.

The only other thing I can think of is that my dev environment is running php 7.2 but the production server (which is working fine) is running 5.6. Might that have anything to do with this issue?

Share Improve this question asked Jan 6, 2018 at 16:26 jtenclayjtenclay 1011 silver badge2 bronze badges 3
  • PHP docs on count do mention count new warnings if invalid countable type variables are passed. Are you able to share the code you believe to be throwing the error. – Andrew Commented Jan 6, 2018 at 16:40
  • in addition to what andrew said, it realy means that you always had a bug, or at least bug code, but there were just nonnoticeable manifistation of it – Mark Kaplun Commented Jan 6, 2018 at 16:45
  • Looks like the problem was my Jetpack plugin, which isn't completely compatible with PHP 7.2 yet. A little more info is below. Thanks guys! – jtenclay Commented Jan 6, 2018 at 21:53
Add a comment  | 

1 Answer 1

Reset to default 0

Turns out the problem was Jetpack. I looked through the <head> to see where in the stack it was breaking and it was right in the middle of the Jetpack plugin code.

Looks like it's being worked on here: https://github/Automattic/jetpack/issues/8156 under "PHP warnings." Since Jetpack isn't necessary for my dev server on this project, I deactivated it and haven't had any errors since.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745327113a4622709.html

相关推荐

  • wp head - &quot;Warning: count()&quot; printing in Page templates

    I recently made a local copy of an existing site to make development changes. Most everything is working fine in the loc

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信