How to Hide Error Messages in WordPress

On this page
  1. What these settings do
  2. Logging Errors Instead of Displaying Them
  3. Summary

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);

What these settings do

  • WP_DEBUG disables WordPress debugging mode.
  • WP_DEBUG_DISPLAY prevents errors and warnings from being shown on the website.
  • display_errors instructs 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.

Didn't find an answer?

Our support team is here for you 24/7 – write to us and we will help you sort it out.