WordPress debug (WP_DEBUG) settings reference
When troubleshooting errors on your WordPress site, enabling various debugging options can make a huge difference. In this article, we'll take a look at the various WordPress debug settings available to you.
PHP debugging
Enable debugging
Debugging is enabled by setting the WP_DEBUG
constant to true
within your wp-config.php
file like this:
define( 'WP_DEBUG', true );
Note that you should only enable debugging on staging sites, or less optimally, sites that you are actively troubleshooting. Aside from performance implications, it's possible that debugging can also leak additional information and pose a potential security risk.
Change debugging behavior
The following options are used in conjunction with the WP_DEBUG
setting. If debugging is turned on, these options determine how debug messages are handled.
Enable WordPress debug logs
In addition to simply turning debugging on, you can also control how debugging behaves, such as if messages should be output to the log. To enable logging, the following can be set within your wp-config.php
file:
define( 'WP_DEBUG_LOG', true );
Setting this option to true
will enable logging to the default location of /wp-content/debug.log
. For more information on WordPress debug logging, see our WordPress debug logs article.
Hide WordPress debug messages
By default, WordPress will display any error message unless told otherwise. Displaying errors can be useful when working on development or staging sites, but should be turned off on any production environments. This is set within your wp-config.php
file like this:
define( 'WP_DEBUG_DISPLAY', false );
Script debugging
Properly registered styles scripts will include both a minified and non-minified versions. By enabling the SCRIPT_DEBUG
option, you can load the non-minified Javascript and CSS to aid in troubleshooting issues.
define( 'SCRIPT_DEBUG', true );
Database query debugging
When debugging things like slow database queries, the SAVEQUERIES
setting can be help to track down issues.
define( 'SAVEQUERIES', true );
Note: This setting in particular can have a significant impact on performance. Never enable it on production sites except as a last resort and immediately disable it when not actively in use.