Category: WordPress


WordPress Easy way to hide PHP warnings and errors in WordPress

Sometimes you have a plugin or a theme in WordPress that has a php warning, but it is highly dependent on another piece of code that you cannot fix without doing some intricate code forking.

For example, earlier today, I got this warning message:
Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/post-template.php on line 284

First of all, that is quite possibly the most poorly written warning/error message. No one can easily understand this message without immediately copying and pasting it into Google. Which is what I did. Luckily, I found a simple solution for hiding warning messages like this.

Add this to your wp-config.php file:

define('WP_DEBUG', false);

Here is a way more aggressive version if that doesn’t work:

define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );

That’s it. w00t!