Count Function WordPress Theme Submission Issue

Hello Sir

I submitted theme and reviewer give us a error three times.

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

I checked my wordpress theme lots of time but i didn’t find this error in my theme.
I checked it in different PHP version with different WordPress version but no error found.

Can you tell me how this error comes.

Please suggest us a better solution because i don’t want to sumit my theme again with this issue.



Check out this relevant issue on the WP Trac website:

The global-mismatch problem is surfaced in cases where get_the_excerpt() is
called outside of the post loop, on posts that don’t have a defined excerpt. In
these cases, the post globals - used to generate a fallback excerpt - may refer
to the incorrect object, resulting in PHP notices or other unpredictable

The reviewers use their own posts and pages when testing, so you will need to create some posts without excerpts to try and reproduce the problem.

This warning was added in PHP 7.2, so make sure you are using that version or newer, and that you have WP debugging enabled.

1 Like