I'm using the_content()
function for elementor plugin implement, but warning comes up once I use this function:
Warning: count(): Parameter must be an array or an object that implements Countable
How can I fix this count() warning?
I'm using the_content()
function for elementor plugin implement, but warning comes up once I use this function:
Warning: count(): Parameter must be an array or an object that implements Countable
How can I fix this count() warning?
Share Improve this question asked Jul 13, 2020 at 9:06 Yotam DahanYotam Dahan 1096 bronze badges 4 |1 Answer
Reset to default 1I noticed this error myself too when using the Elementor plugin. It is only displayed when WP_Debug
is set to true
.
The location of the warning is wp-includes/post-template.php
. This is not a theme location, so the short version is that you're not responsible for it.
The error only appears when using Elementor. I think that the Elementor developers should fix this error, because it is their plugin that 'conflicts' with a wp-includes
file. I expect that this will be fixed in a future version of Elementor.
My conclusion is that you can ignore this error message. It is only visible when WP_Debug is true
and normal users seldom enable this. Plus, it is only a warning
and not an error
. As far as I know, the Elementor plugin is not hindered by it. (However, this could turn into an error
in a future version of PHP when it is not fixed.) But for now you shouldn't worry.
UPDATE PER 15/7/2020:
This error is caused by only using the_content()
function outside of a loop. This function should be put inside a loop.
So replace
the_content();
with
while ( have_posts() ) : the_post();
the_content();
endwhile;
Replacing this made the error disappear, while my content and everything didn't change. My guess now is that the count()
function has to do sth with the wp count in the loop.
wp-includes/post-template.php
) you can see that it is an error in a WP file. You are not responsible for the wp-includes folder, so my guess is that the Elementor developers should fix this. Btw, normal users don't have PHP warnings enabled in the first place (and as far as I know the Elementor plugin works normal). Plus, it's awarning
and not anerror
. – ralphjsmit Commented Jul 13, 2020 at 11:32