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

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

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

How To Fix Php 7 2 Warning Count On The Content

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.


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


Tags: ✓
Autor: Dimitar Radev | Modified: March 1, 2019 at 4:37 am | Category: WordPress

Leave a Reply

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

  • robson says:

    I am still very confused I dont want to break my website can you help or give me slower guide

  • Advertising

    Related posts

    Get current category (taxonomy) children and prepare them for options element.

    Today I will share something that I use often. Getting the children of the current queried category or taxonomy and making from them …

    How to get the_content with all HTML tags inside functions.php?

    To get the post or page content inside WordPress functions.php with all the HTML tags you need to use the_content filter. This method …