
When you’re building a WordPress website, you’re bound to run into a few issues along the way. Without some insight into what’s causing the problem, tracking down the culprit can be a real headache. You might find yourself guessing—disabling plugins, switching themes, or digging through code—hoping something sticks. It’s a frustrating way to work, and without proper error messages or logs, even simple fixes can take far longer than they should.
Table of Contents
- What is WordPress Debugging?
- WordPress Debugging Constants
- Locating the wp-config.php File
- Different Debugging Configurations
- How to Enable WordPress Debugging
- Try Our WordPress Debugger Log Viewer Plugin
- FAQ: WordPress Debugging
What is WordPress Debugging?
Fortunately, WordPress provides a way to display errors and/or write them to a WP debug log, but this feature is disabled by default. The reason is simple: enabling debugging on live sites can create security and performance risks. Detailed error messages may expose sensitive information such as file paths, plugin names, or database details that attackers could exploit. Debugging can also clutter or slow down a site when errors are logged unnecessarily.
For these reasons, we at Fun With Plugins recommend leaving debugging disabled on live sites. If you run into technical issues, enable debugging temporarily while troubleshooting, then disable it again once your site is back to normal.
WordPress debugging is controlled by three PHP constants. A constant is like a fixed variable in programming—it holds a value that doesn’t change during execution. These constants are defined in wp-config.php, a critical file located in your site’s root directory. By editing this file, you can turn debugging features on or off to help track down issues.
WordPress Debugging Constants
WP_DEBUG
This is the master switch. Setting WP_DEBUG to true enables WordPress debugging, but by itself it does not display errors or write them to a log. Pairing it with either WP_DEBUG_LOG or WP_DEBUG_DISPLAY makes debugging useful.
WP_DEBUG_LOG
When enabled, this constant writes errors to the debug.log file (located in the /wp-content/ directory). This is the safest option because errors are hidden from visitors but still available for review.
WP_DEBUG_DISPLAY
When set to true, this constant outputs errors directly on your site’s pages. While helpful during development, this should never be enabled on a live site since visitors will see the error details.
Locating the wp-config.php File
The file that controls debugging options is wp-config.php. It also stores your database connection details, authentication keys, and other critical settings.
You’ll find wp-config.php in your site’s root directory. While that location is straightforward, hosting providers may use different folder names: public_html, htdocs, httpdocs, or something custom. The easiest way to confirm you’re in the right place is to look for index.php sitting alongside wp-config.php. If both files are present, you’ve found the root.
Warning: Editing this file incorrectly can crash your site. Always make a backup of wp-config.php before making changes so you can quickly restore it if needed.
Different Debugging Configurations
Here are the three most common setups:
Option 1 (Default) – Debugging Disabled
Best for live sites.
define( ‘WP_DEBUG’, false );
Option 2 – Debugging Enabled, Errors Displayed and Logged
Best for development sites.
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, true );
Option 3 – Debugging Enabled, Errors Logged but Not Displayed
Safest option if debugging must run on a live site.
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, false );
How to Enable WordPress Debugging
- Decide how you want debugging configured.
- Back up your wp-config.php file.
- Open wp-config.php with a code editor or file manager.
- Locate this line:
- define( ‘WP_DEBUG’, false );
- Change it to:
- define( ‘WP_DEBUG’, true );
By itself, this only enables debugging—it won’t log or display errors. You’ll need to adjust the other constants as well.
Write Errors to the WP Debug Log
define( ‘WP_DEBUG_LOG’, true );
With this enabled, WordPress writes errors to the WP Debug Log located at /wp-content/debug.log.
Display Errors on Screen
define( ‘WP_DEBUG_DISPLAY’, true );
Errors will appear on your site’s pages. For live sites, set this to false.
Try Our WordPress Debugger Log Viewer Plugin
If you’re tired of digging through files to find the WP debug logs, our plugin makes it simple. View debug.log directly from your WordPress dashboard, filter errors by keyword, and clear the log when you’re done troubleshooting—all without leaving the admin area.
FAQ: WordPress Debugging
1. How do I enable debugging in WordPress?
Edit your wp-config.php file and set:
define( ‘WP_DEBUG’, true );
This enables WP debugging but won’t log or display errors until you configure the other constants.
2. Where can I find the WordPress debug log?
If WP_DEBUG_LOG is enabled, the WP log file is located at /wp-content/debug.log.
3. Is it safe to enable debugging on a live site?
It’s best to use debugging on staging or development sites. If you must debug a live site, set:
define( ‘WP_DEBUG_DISPLAY’, false );
so visitors won’t see errors.
4. What’s the difference between WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY?
- WP_DEBUG → Master switch to turn debugging on/off.
- WP_DEBUG_LOG → Saves errors to debug.log.
- WP_DEBUG_DISPLAY → Shows errors on-screen (not recommended for live sites).