Enable Debug Mode in WordPress โ
WordPress debug mode reveals PHP errors, notices, and warnings that are hidden in production. It's essential for diagnosing issues with plugins, themes, or custom code.
Enabling debug mode โ
Edit wp-config.php in your WordPress root directory. Find the line that says define( 'WP_DEBUG', false ); and replace the debug section with:
// Enable debug mode โ show all errors
define( 'WP_DEBUG', true );
// Log errors to a file instead of displaying on screen
define( 'WP_DEBUG_LOG', true );
// Hide errors from visitors (write to log only)
define( 'WP_DEBUG_DISPLAY', false );
// Suppress deprecated notices (optional โ reduces noise)
define( 'SCRIPT_DEBUG', true );With WP_DEBUG_DISPLAY set to false, errors are written to /wp-content/debug.log and not shown to visitors.
Viewing the debug log โ
# SSH into your server and tail the log
tail -f /home/cpanelusername/public_html/wp-content/debug.log
# Or view the last 100 lines
tail -n 100 /home/cpanelusername/public_html/wp-content/debug.logOr download it via cPanel โ File Manager โ navigate to public_html/wp-content/debug.log.
Enabling error display (for local/dev only) โ
On a local development environment where exposing errors to the screen is acceptable:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true ); // Show errors on screen
define( 'WP_DEBUG_LOG', false );
@ini_set( 'display_errors', 1 );WP_DEBUG_DISPLAY to true on a production server shows error details to all visitors โ including database names, file paths, and code excerpts. Use WP_DEBUG_LOG instead. Common errors and what they mean โ
| Error | Likely cause |
|---|---|
Call to undefined function | A plugin or theme function is missing โ plugin may not be active or is outdated |
Fatal error: Cannot redeclare | Two plugins or theme files defining the same function |
PHP Warning: include_once | A file is missing โ deleted plugin files or incomplete upload |
WordPress database error | MySQL connection issue or a query error โ check DB credentials in wp-config.php |
Maximum execution time exceeded | A process took too long โ increase max_execution_time in PHP settings or optimize the slow query |
Disabling debug mode โ
When you're done, set WP_DEBUG back to false:
define( 'WP_DEBUG', false );Or remove the debug lines entirely โ the default WordPress wp-config.php has WP_DEBUG set to false.
Query Monitor plugin โ
For more detailed debugging without editing wp-config.php, install the Query Monitor plugin. It shows database queries, PHP errors, hooks and actions, HTTP API calls, and page load performance โ all in a browser toolbar panel visible only to logged-in admins.

