WordPress includes several settings that you can use to help debug the main application, themes, custom code, and more.
Note: Before making any changes to your WordPress configuration file, make a backup of the file in place.
Enabling debugging mode
Generally, these settings are intended for use by developers and should not be used on live sites. However, you can also use them in specific scenarios to help troubleshoot issues you may be experiencing with third-party code, such as plugins or themes.
To enable debugging mode in WordPress, follow these steps.
- Log in to cPanel.
- Using the cPanel File Manager or your preferred text editor, open the wp-config.php.
- To enable debugging mode, add the following line to the wp-config.php file.
Note: When this setting is enabled, WordPress displays all PHP errors, notices, and warnings.define('WP_DEBUG', true);
- Save your changes and exit the text editor. Debugging mode is now active.
Note: Disable debugging mode by modifying the line in the wp-config.php file as followsdefine('WP_DEBUG', false);
Additional debug options
There are several additional settings you can use to control the debugging information that WordPress provides.
WP_DEBUG_LOG
define('WP_DEBUG_LOG', true); |
WP_DEBUG_DISPLAY
define('WP_DEBUG_DISPLAY', false); |
SCRIPT_DEBUG
define('SCRIPT_DEBUG', true); |
Logging database queries
If you are experiencing database issues with WordPress, you can enable query logging. When query logging is enabled, the following items are saved in the global $wpdb->queries array.
- The actual database query
- How long the query takes to run
- The function which called the query
To enable database query logging, add the following line to the wp-config.php file.
Note: Enabling this setting affects your site's performance. You should only enable this setting for as long as it is necessary to debug a problem. Once finished, make sure to disable it.
define('SAVEQUERIES', true);
The following PHP code snippet demonstrates how to dump the entire contents of the $wpdb->queries array to a page.
queries ); ?>
Was this article helpful? If not please submit a request here
How helpful was this article?
Thanks for your feedback!