How to remove error notices using WordPress’s WP_DEBUG

A neat trick I learned today to remove or adjust PHP error reporting when using `WP_DEBUG`. It’s often the case that a theme or plugin author has either not written code with debug on or perhaps supporting an older version of PHP so error notices can hinder the output visually or fill up your log file. A theme I was working on that caused me to find a solution was adding 8k lines of debug output to the log file every couple hours!

In your `wp-content` folder create a new folder called `mu-plugins` and in that folder create a php file with the error level you want, for example:

//Turns off notices
error_reporting(E_ALL ^ E_NOTICE);

If you are using PHP 5.5 +, you will get deprecated noticed for WordPress’s mysql_* functions, you can turn them off using:

error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);

Or for something really robust, which happens to be the case a lot.



I you develop themes/plugins please turn on debugging and support at the very least PHP 5.4!


One thought on “How to remove error notices using WordPress’s WP_DEBUG

  1. Thank you! I was fighting with notices for a while now and it turns out that placing that line in must use plugins is the way to go.
    It won’t work when place in wp-config.php and placing it in theme’s functions.php is not a good solution. So, thanks again!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s