How to Hide PHP Warnings and Notices in WordPress

I occasionally receive a message from a user saying, “I see several PHP notifications and warnings on my page.”

The majority of the time, issues are unimportant (although the plugin/theme creator should be informed so they may address problems in a future release). Most of the time, PHP alerts and warnings on a production site are nothing to be concerned about.
Because the developer needs to maintain compatibility with older versions of both WordPress and PHP, some of these can even be generated.

Solution:

If you simply set WP_DEBUG to false in your wp-config.php file you should be fine. These don’t affect your site in any way.

The issue is that the aforementioned does not always work.
The majority of the time, cheap shared hosts that compel the display of PHP alerts and warnings can cause this.
In that case, you can replace this line from your wp-config.php file:

define('WP_DEBUG', false);

with this:

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

I hope that helps someone out there!

Related Posts