2

I'm working on a development site that has some plugins that produce notices. It's a bit annoying during development when you only want to see the errors your own code produces.

How can you turn off notices in WordPress but keep reporting of errors enabled?

I thought this should work, but it doesn't:

define( 'WP_DEBUG', true );
error_reporting(E_ALL & ~E_NOTICE);

Edit: I should point out that I added this code to the wp-config.php, just to be clear.

2
  • That's a PHP-wide setting, plugins don't get loaded into a neat sandbox that you can tweak on a per-sandbox basis, it's all loaded into the same communal codespace, otherwise filters etc wouldn't work. Instead you're better off investigating better debugging tools than printing things straight to the browser, such as query monitor, debuggers such as xdebug, or at least logging messages to an error log. Printing notices or errors to the frontend can expose information and should be considered a security problem
    – Tom J Nowell
    Feb 8, 2022 at 16:41
  • This question is similar: wordpress.stackexchange.com/questions/239501/…
    – Flimm
    Apr 29 at 14:03

1 Answer 1

1

Alternatively you can create a debug logging file for where you can read the errors. Source: http://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Log

/**
 * This will log all errors notices and warnings to a file called debug.log in
 * wp-content (if Apache does not have write permission, you may need to create
 * the file first and set the appropriate permissions (i.e. use 666) ) 
 */

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.