WP Snipp Ninja

How to Fix PHP 7.2 “Warning: count()” on get_the_content() or the_content() in WordPress

Author: Dimitar Radev | Posted on: July 24, 2018 |

Looking to fix this “Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/post-template.php on line 284” or something along those lines?

The issue is coming from inside the get_the_content function, it counts global $page which in some (or more than some) cases can be null and that is not a supported value for countable in PHP 7.2+. and we get an E_WARNING

I had this issue using Sage and PHP 7.2 it was breaking the_content() and I got the content from the meta fields by using get_post_field(‘post_content’, $post->id) and running it through the_content filter so we can get all the formatting right.

//Get the_content from a post or page
function zi_content()
  global $post;

  return apply_filters('the_content', get_post_field('post_content', $post->id));


Just replace get_the_content in your function with zi_content() or just echo it into your template file like so:

echo zi_content();


Article keywords

  • About the Author

     Dimitar Radev

    Hey, I'm Dimitar "B1-0S" Radev or D in short. I'm a WordPress Developer for nearly 10 years and I have in-depth knowledge in creating Custom WordPress Themes, Plugins, Commercial Themes Edits, and WooCommerce Storefronts. In the last two years, I'm specializing in Technical SEO for WordPress websites.

    Follow Dimitar Radev on Social Media

    Leave a Reply

    Your email address will not be published. Required fields are marked *