How to hide PHP Warnings and Notices in WordPress?

Created at 08-Feb-2023 , By samar

You can hide PHP Warnings and Notices in wordpress by using the WP_DEBUG constant in wp-config.php file or you can use php ini_set('display_errors','Off'); and ini_set('error_reporting', E_ALL ); functions to hide the php warnings and notices from the front-end of your website.

The ini_set function in PHP allows you to change the configuration settings of your PHP installation at runtime. The ini_set('display_errors','Off'), turns off the display of errors, while the ini_set('error_reporting', E_ALL ) function, sets the error reporting level to E_ALL, which reports all errors and warnings.

Hide PHP Warnings and Notices in wordpress using WP_DEBUG constant

WP_DEBUG constant is used to control the debugging mode in WordPress. By setting it to false in your wp-config.php file, you can turn off warnings and notices.

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

The first line, WP_DEBUG, sets the WordPress debugging mode to off, and the second line, WP_DEBUG_DISPLAY, turns off the display of errors. This way, the warnings and notices will not be shown on the front-end of your website, but they will still be logged in the error logs.

Hide PHP Warnings and Notices in wordpress using ini_set function in wp-config.php

If the above method does not work then you can replace define('WP_DEBUG', true); with the below code in wp-config.php file which exists at the root of wordpress project directory.

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

Enable debug logging in wordpress


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

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.