Post-Template error warning at top of every page

The following error code is at the top of all the pages on my site:

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/12/d100333497/htdocs/clickandbuilds/DailymirrorDev/wp-includes/post-template.php on line 284

It is NOT at the top of the pages that are in the admin section (dashboard, etc).

The code at that point in the referenced file is below:

Line 280: // If post password required and it doesn’t match the cookie.
Line 281: if ( post_password_required( $post ) )
Line 282: return get_the_password_form( $post );
Line 283:
Line 284: if ( $page > count( $pages ) ) // if the requested page doesn’t exist
Line 285: $page = count( $pages ); // give them the highest numbered page that DOES exist

I am open to any suggestions on how to fix this. This theme was put on a fresh install of WP.

Hi @Smicky,

Thanks for reaching out.

It’s a file from Wordpress core, and the code has no issue. The one you’re getting is a warning and not an error, notices and warnings are visible if your debugging is active. Please edit your site’s wp-config.php and set WP_DEBUG to false. Then upload it again.

Thanks!

Thanks for the info @Rad. I went to edit the wp-config but didnt have a line of code turning the debug off/on. I know that is usually part fo the wp-config file so just in case, I went ahead and added the following line of code but the warning is still showing up.

define(‘WP_DEBUG’, false);

When I went to compare my wp-config file to the wp-config-sample, the only other difference (aside from the debug line being in the sample file) was that this line of code was at the top of the file:

define(‘FS_METHOD’, ‘direct’);

I dont know what the Fileseystem method would have to do with debugging but it was a difference.

For a little background, I was in a hurry when i was starting this site so I let my hosting do the ‘clickandbuild’ setup of wordpress for me. Usually I do an all manual setup but the last couple of times I have let the hosting computer do it for me without any issues…until now.

If the best solution is for me to go back and start with a complete start from scratch, I can, just let me know what you think.

Hello There,

No need to start a complete from scratch yet. Please comment the line:

//define('FS_METHOD', 'direct');

And then go to your dashboard WP Dashboard > Updates and re install your WordPress. There might be some WP files that were corrupted or something. If nothing is helping, please provide us your WP access and your ftp credentials in a secure note so that we can investigate further.

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.