WordPress includes several built-in settings to help debug the core application, themes, plugins, and custom code. These settings are turned on by editing the wp-config.php file.
About WordPress debugging
Debugging settings reveal PHP errors, warnings, and notices, which makes troubleshooting easier when something on your site stops working. These settings are typically used by developers and are not recommended on live production sites unless you're actively investigating an issue.
Warning: Always back up wp-config.php before editing it. A syntax error in this file will take your site offline.
Before you begin
- cPanel access for your hosting service. You need to edit wp-config.php in your WordPress installation directory.
- A backup of wp-config.php. Copy the file before making changes so you can restore it if needed.
- A text editor. Use the cPanel File Manager's editor or your preferred local text editor.
Step 1: Open wp-config.php
- Log in to the Exact Hosting client area and open cPanel for your service.
- Open the File Manager in cPanel.
- Navigate to your WordPress installation directory (typically public_html).
- Open wp-config.php for editing.
Step 2: Enable debugging mode
Add the following line to wp-config.php to enable the main debug flag. When enabled, WordPress displays all PHP errors, notices, and warnings.
define('WP_DEBUG', true);Save your changes and close the file. Debugging mode is now active.
To disable debugging mode later, change the value to false:
define('WP_DEBUG', false);Step 3: Use additional debug options
The settings below give you finer control over how WordPress reports errors. Add each line to wp-config.php.
Setting | What it does |
|---|---|
WP_DEBUG_LOG | Saves all error information to debug.log in the wp-content directory. Disabled by default. Enable with: define('WP_DEBUG_LOG', true); |
WP_DEBUG_DISPLAY | Controls whether errors and warnings appear on web pages. Enabled by default. Hide them by disabling it: define('WP_DEBUG_DISPLAY', false); |
SCRIPT_DEBUG | Loads development versions of core CSS and JavaScript files instead of compressed versions. Useful when testing changes to built-in .js or .css files. Disabled by default. Enable with: define('SCRIPT_DEBUG', true); |
Tip: A common debugging combination is to set WP_DEBUG to true, WP_DEBUG_LOG to true, and WP_DEBUG_DISPLAY to false. This logs errors silently to a file without exposing them to site visitors.
Step 4: Log database queries
If you're troubleshooting database issues, enable query logging. When enabled, WordPress saves the following data to the global $wpdb->queries array:
- The full database query
- How long the query took to run
- The function that called the query
Add the following line to wp-config.php to enable query logging:
define('SAVEQUERIES', true);Warning: Query logging affects site performance. Enable it only while debugging, and disable it as soon as you're finished.
To inspect logged queries from a PHP template, use code similar to the following inside a logged-in admin context:
<?php\nglobal $wpdb;\nprint_r( $wpdb->queries );\n?>
Next steps
- Back up your site before debugging. See WordPress manual backup (Softaculous).
- Test fixes on a staging site first. See Creating a Managed WordPress staging site.
- Disable debugging after troubleshooting. Always set WP_DEBUG back to false on production sites.
Questions? Contact Exact Hosting Support.
Related articles
- Hardening Your WordPress Site — prevent the issues you are debugging
- Troubleshooting "500 Internal Server Error" — server error guide
- Troubleshooting "Error Establishing a Database Connection" — database error guide
How helpful was this article?
Thanks for your feedback!
Do you still need help? If so please submit a request here.