This article describes several settings you can use to help debug WordPress.
WordPress includes several settings that you can use to help debug the main application, themes, your own custom code, and more.
Generally, these settings are intended for use by developers and should not be used on “live” sites. However, you can also use them in certain 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:
When this setting is enabled, WordPress displays all PHP errors, notices, and warnings.
Save your changes and exit the text editor. Debugging mode is now active.
When you are done, disable debugging mode by modifying the line in the wp-config.php file as follows:
There are several additional settings you can use to control the debugging information that WordPress provides:
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:
To enable database query logging, add the following line to the wp-config.php file:
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, and then disable it.
The following PHP code snippet demonstrates how to dump the entire contents of the $wpdb->queries array to a page:
<?php global $wpdb; print_r( $wpdb->queries ); ?>
To view the official WordPress debugging documentation, please visit https://codex.wordpress.org/Debugging_in_WordPress.