By default, WordPress can display PHP warnings, notices, and other error messages when debugging is enabled. On production websites, displaying these messages is not recommended because they can expose sensitive information about your site’s configuration.
To disable the public display of errors, edit the wp-config.php file located in your WordPress installation directory.
Find the following lines:
define('WP_DEBUG', true);
Or add the following configuration before the line:
/* That's all, stop editing! Happy publishing. */
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
Table of Contents
What these settings do
WP_DEBUGdisables WordPress debugging mode.WP_DEBUG_DISPLAYprevents errors and warnings from being shown on the website.display_errorsinstructs PHP not to display errors to visitors.
Logging Errors Instead of Displaying Them
If you want WordPress to record errors without showing them publicly, use the following configuration:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
WordPress will then save error messages to:
/wp-content/debug.log
This allows you to troubleshoot issues while keeping error messages hidden from visitors.
Summary
For production websites, it is recommended to disable the public display of errors and use error logging instead. This improves security, prevents visitors from seeing technical messages, and makes troubleshooting easier when issues occur.