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 |1 Answer
Reset to default 0Turns 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
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