When troubleshooting issues or developing a WordPress site, it’s often necessary to turn on debugging to see PHP errors and warnings. WordPress provides built-in constants for this: WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY.
Here’s how to enable or disable them:
1. Open your wp-config.php file
You’ll find wp-config.php in the root directory of your WordPress installation (where folders like wp-content and wp-admin are located).
2. Enable WordPress Debugging
Add or update the following lines above this line:
/* That's all, stop editing! Happy publishing. */
// Enable WP Debugging
define('WP_DEBUG', true);
// Log errors to a file
define('WP_DEBUG_LOG', true);
// Display errors on the page
define('WP_DEBUG_DISPLAY', true);
// Optional: Force errors to be shown even if PHP settings hide them
@ini_set('display_errors', 1);
What this does:
-
WP_DEBUGenables WordPress to show PHP errors, notices, and warnings. -
WP_DEBUG_LOGsaves these errors to a file calleddebug.loginside thewp-contentfolder. -
WP_DEBUG_DISPLAYcontrols whether errors are shown on the page.
3. Disable WordPress Debugging
When your site is live, you should always turn debugging off to avoid exposing sensitive information.
Update the lines like this:
// Disable WP Debugging
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);
define('WP_DEBUG_DISPLAY', false);
Or simply comment them out if you don’t need them at all.
4. Important Notes
-
If
WP_DEBUG_DISPLAYis set tofalse, errors won’t appear on screen, but ifWP_DEBUG_LOGistrue, they will still be saved towp-content/debug.log. -
Always make a backup of your
wp-config.phpfile before making changes. -
You may need to manually create or delete the
debug.logfile if needed.
Quick Reference
| Constant | Purpose | Typical Value |
|---|---|---|
WP_DEBUG |
Master switch for all debugging | true or false |
WP_DEBUG_LOG |
Save errors to a log file | true or false |
WP_DEBUG_DISPLAY |
Show errors on screen | true or false |