Removing warnings and notices from production servers

As many have already commented, it is better to fix the source of the issue than to hide the messages. That said, these types of messages should never be displayed on production server but, since you just never know, it is also a good idea to disable them on all servers (local development machine, development machines, etc.).

We use the following settings in wp-config.php to disable the display of all warnings, notices, errors, etc. and then use tail -f wp-content/debug.log to see the errors as we work:

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

Sometimes Notices don’t include a backtrace so you can’t see what’s causing the message. Please see my answer to a similar question as it includes details on how to get a backtrace for such messages.

If you are still seeing warnings and info and such and you’ve followed my advice in this answer, then it is likely a plugin or the theme itself is re-enabling the display of warnings and info.

WP_DEBUG_DISPLAY is a constant that tells WordPress to run the following code:

if ( WP_DEBUG_DISPLAY ) {
    ini_set( 'display_errors', 1 );
} elseif ( null !== WP_DEBUG_DISPLAY ) {
    ini_set( 'display_errors', 0 );
}

This code is in wp-includes/load.php and is, if not the first, one of the very first files included in the WordPress bootstrapping procedure. The function that this code appears in is called in wp-settings.php which is the first file included after wp-config.php. This code is called before plugins are loaded and executed.

If a plugin producer has ini_set( 'display_errors', 1 ) in their code, it will override what you’ve got in wp-config.php and continue showing PHP errors, warnings, info, etc. There is no way, really, to override this. Try searching your entire plugins folder for ini_set to see if you can spot the culprit. You should probably also check your theme while you are at it.