PHP warnings and notices give useful information to the developers, but it’s not good for the users to see them. PHP warnings and notices can appear on the front end of the site if you are updating the PHP version on your host and have incompatible themes or plugins or just there is something not so good in your code in WordPress. Most of the time these are nothing to worry about.

For better user experience you’ll want to hide them from the front end and log them in a separate file instead.

PHP Snippet: How to Disable PHP Error Reporting in WordPress

In the root of your WordPress website, find and open the wp-config.php file. Set WP_DEBUG to false.

define('WP_DEBUG', false);

If, for some reason, the above does not work, try adding the following:

ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Refresh the page to check the result.

Learn more about the difference between PHP notice and warning.

Share:

Leave a Reply