WordPress Debugging Techniques – hide error notices using custom mu-plugin?

I have an old WordPress site running under PHP 5.4 which is throwing a lot of minor error notices such as undefined index.

I’m not able to fix these – the errors are coming from a bunch of 3rd party plugins on a site that I did not develop and don’t have the time to fix.

Read More

The quick fix for the moment is to hide the error notices.
Adding this to wp-config.php hides errors from the screen, writing them to the debug.log file:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

I’d like to decrease the verbosity of the errors in the log file by using something like:

error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);

I read the only way to do this is by creating a custom must-use plugin (mu-plugin).

Is this still the current/best technique to do this (as of WordPress 4.2.2)?
(without using a 3rd party debug tool).

Does anyone have a sample of this type of plugin for reference? I’m finding it difficult to locate information on this.

Related posts

Leave a Reply

1 comment

  1. you can change on wp-config.php file replace this code .

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    

    replace with

    define('WP_DEBUG', false);
    define('WP_DEBUG_LOG', false);
    

    now your error message hide.