WordPress Debug Mode

WordPress showing a white screen, a 500 error, or a plugin behaving strangely — but you have no idea why? Debug Mode is WordPress's built-in tool that reveals hidden PHP errors so you can fix problems precisely and efficiently.

This guide covers every debug constant available in WordPress — WP_DEBUG, WP_DEBUG_LOG, SCRIPT_DEBUG — plus free tools like Query Monitor, with clear warnings about what to never do on a live production server.

1. What Is WordPress Debug Mode?

By default, WordPress suppresses all PHP errors, warnings, and notices. Visitors only see a white screen or "There has been a critical error" without any indication of the actual cause.

Debug Mode is a set of constants in wp-config.php that tells WordPress to:

Warning: Never enable WP_DEBUG_DISPLAY = true on a live production website. Error messages can expose server paths, database names, and other sensitive information to malicious users.

2. Enabling WP_DEBUG in wp-config.php

The file wp-config.php lives in your WordPress root directory (same folder as wp-admin and wp-content). You can edit it through DirectAdmin's File Manager or via FTP.

Find this line in wp-config.php:

define( 'WP_DEBUG', false );

Replace it with the appropriate configuration:

// Enable Debug Mode
define( 'WP_DEBUG', true );

// Write errors to a log file (recommended for production)
define( 'WP_DEBUG_LOG', true );

// Hide errors from the screen (safer for live sites)
define( 'WP_DEBUG_DISPLAY', false );

// Load unminified JS/CSS files
define( 'SCRIPT_DEBUG', true );

Tip: The define('WP_DEBUG', false); line must always appear before the /* That's all, stop editing! */ comment. Do not add constants after that line.

3. WP_DEBUG_LOG vs WP_DEBUG_DISPLAY

These two constants serve different purposes — choose the right combination for your situation:

ConstantFunctionBest For
WP_DEBUG_DISPLAY = trueShows errors directly in the browserLocal dev only
WP_DEBUG_DISPLAY = falseHides errors from the screenProduction
WP_DEBUG_LOG = trueWrites errors to /wp-content/debug.logDev & Production

For production servers: use WP_DEBUG_LOG = true with WP_DEBUG_DISPLAY = false to capture errors silently without exposing them to visitors.

4. SCRIPT_DEBUG for JavaScript

SCRIPT_DEBUG forces WordPress to load the full, non-minified versions of JavaScript and CSS files instead of compressed bundles, making it much easier to read and debug code in browser DevTools.

define( 'SCRIPT_DEBUG', true );

Use this constant when:

5. Reading the Error Log from debug.log

When WP_DEBUG_LOG = true is set, WordPress automatically creates a log file at /wp-content/debug.log.

How to read debug.log:

  1. Open File Manager in DirectAdmin
  2. Navigate to public_html/wp-content/
  3. Right-click debug.log → View or Edit
  4. Scroll to the bottom — the most recent errors appear at the end of the file

Common Error Examples

[16-May-2026 10:30:45 UTC] PHP Fatal error: Uncaught Error: Call to undefined function
  plugin_function() in /home/user/public_html/wp-content/plugins/myplugin/functions.php:42

[16-May-2026 10:30:46 UTC] PHP Warning: include(/wp-content/themes/mytheme/missing-file.php):
  Failed to open stream: No such file or directory in /home/user/public_html/wp-settings.php:500

The first error pinpoints a plugin calling an undefined function. The second shows a theme trying to include a file that doesn't exist. Both tell you exactly where to look.

5b. Interpreting Common Error Types in debug.log

Errors logged to debug.log fall into several categories, each pointing to a different root cause and fix. This reference table helps you triage issues quickly:

Error Type Meaning Common Cause First Step to Fix
PHP Fatal error Critical — script execution stops immediately Calling an undefined function, class not loaded, syntax error Read the stack trace, check the plugin/theme named in the path
PHP Warning Non-fatal but abnormal behavior Undefined variable, missing include file, wrong argument type Update the plugin/theme, verify file paths
PHP Notice Informational — minor issue Uninitialized variable, deprecated function usage Usually safe to ignore short-term; fix before go-live
PHP Deprecated Feature will be removed in a future PHP version Plugin using old WordPress or PHP functions Update the plugin or contact the developer
Parse error PHP cannot parse the file — syntax broken Typo in code, missing semicolon or closing brace Check the exact line number, restore a backup if needed

Example: Reading a Stack Trace

A stack trace shows the sequence of function calls that led to the error. Read it bottom-up — the bottom line is where the chain started, the top line is where the error actually occurred:

PHP Fatal error: Maximum execution time of 30 seconds exceeded
  in /home/user/public_html/wp-includes/class-http.php on line 423
  Stack trace:
  #0 /wp-content/plugins/myplugin/import.php(88): WP_Http->request()
  #1 /wp-includes/cron.php(467): myplugin_import_data()
  #2 {main}
  thrown in /wp-includes/class-http.php on line 423

This trace shows that a cron job in myplugin triggered an HTTP request that exceeded the 30-second limit. The fix is either to increase max_execution_time in PHP settings, or break the import into smaller batches.

6. Query Monitor Plugin

Query Monitor is a free developer plugin that displays debug information in a real-time panel in the WordPress Admin Bar — no file editing required.

What Query Monitor shows:

Recommendation: Query Monitor is one of the most valuable tools for any WordPress developer. Install it on staging and local environments for far more detailed diagnostics than debug.log alone. Free on WordPress.org.

6b. Additional Debug Tools Worth Installing

Beyond Query Monitor, several other tools help diagnose specific WordPress problems more efficiently:

Kint Debugger

Kint is a PHP debugging library that renders variables, arrays, and objects as a clean, interactive collapsible tree in the browser — far more readable than var_dump(). Use it in your theme's functions.php with:

d($wpdb->queries); // Display all database queries
dd(get_queried_object()); // Display and halt execution

Health Check & Troubleshooting (WordPress Official)

This official plugin from WordPress.org includes a Troubleshooting Mode that disables all plugins and switches to a default theme — but only for the logged-in admin. Regular visitors continue to see the site normally. This makes it safe to identify plugin conflicts on a live site without downtime.

WP Crontrol

Helps debug WordPress cron jobs that aren't running. It lists all scheduled cron events, shows next run times, and lets you manually trigger any event to test whether it executes correctly — useful when WP_DEBUG_LOG shows cron-related errors.

Finding the Problem Plugin Without Deactivating One by One

Plugin conflicts are among the most common sources of WordPress errors. When multiple plugins interact, the combination can produce behavior that no single plugin causes alone. Here are two efficient methods to isolate the culprit:

Method 1: Health Check Troubleshooting Mode

Install the official Health Check & Troubleshooting plugin from WordPress.org and activate Troubleshooting Mode. This disables all plugins temporarily — but only for the logged-in administrator. Regular visitors see the site normally. Enable plugins one at a time until the problem reappears. The last plugin you re-enabled is the conflict source.

Method 2: Binary Search (Bisection)

For sites with many plugins, binary search is dramatically faster than testing one at a time:

  1. Disable half of your active plugins
  2. If the problem disappears — the culprit is in the disabled group
  3. If the problem persists — the culprit is in the still-active group
  4. Repeat with the suspect half until one plugin remains
Plugin Count One-by-One (O(n)) Binary Search (O(log n)) Time Saved
8 pluginsUp to 8 testsUp to 3 tests~63%
16 pluginsUp to 16 testsUp to 4 tests~75%
32 pluginsUp to 32 testsUp to 5 tests~84%
64 pluginsUp to 64 testsUp to 6 tests~91%

7. Debug Bar Plugin

Debug Bar adds a "Debug" menu to the WordPress Admin Bar with panels covering:

Debug Bar supports additional extensions, including Debug Bar Console which lets you run PHP code directly from the browser panel.

7b. Debugging WordPress on AsiaGB Hosting with DirectAdmin

AsiaGB Hosting uses DirectAdmin as its control panel, which provides several built-in tools that make WordPress debugging straightforward without needing SSH access.

Editing wp-config.php via File Manager

  1. Log into DirectAdmin at yourdomain.com:2222
  2. Click Files → File Manager
  3. Navigate to public_html/ (or wherever WordPress is installed)
  4. Right-click wp-config.php → Edit
  5. Add your debug constants → click Save

Viewing the PHP Error Log Directly in DirectAdmin

DirectAdmin includes a built-in error log viewer so you don't have to navigate through File Manager manually:

  1. In DirectAdmin, go to Advanced Features → Error Log
  2. Select the domain you want to inspect
  3. Recent PHP errors will appear immediately without needing to open debug.log

Changing PHP Version When Errors Indicate a Compatibility Issue

If debug.log shows errors about functions that don't exist or have been deprecated, there may be a PHP version mismatch. DirectAdmin's PHP Selector lets you switch between PHP versions instantly — no server restart needed. For WordPress 6.x, PHP 8.1 or 8.2 is recommended.

Tip: If your site shows a white screen but debug.log remains empty, verify that define('WP_DEBUG', true); is placed before the /* That's all, stop editing! */ line in wp-config.php. WordPress ignores any constants defined after that marker.

8. Turning Off Debug Mode After Fixing Issues

Once you've identified and fixed the problem, disable Debug Mode immediately — especially on production servers.

// Disable Debug Mode (default state)
define( 'WP_DEBUG', false );

// Safe alternative: keep logging but hide from screen
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Also delete the debug.log file after resolving issues — it may contain server paths or partial credential information that should not remain accessible.

Production risk: Forgetting to turn off WP_DEBUG_DISPLAY = true on a live server exposes PHP error messages containing server paths, database hosts, and other information attackers can exploit. Always verify after debugging.

Advanced wp-config.php Constants for Better Debugging

Beyond the core debug constants, several additional settings in wp-config.php improve both debugging capabilities and site stability. Here are the most useful ones organized by environment:

Local Development — Full Debug Configuration

// === Debug (Local Dev) ===
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
define( 'SCRIPT_DEBUG', true );
define( 'SAVEQUERIES', true ); // Logs every DB query to $wpdb->queries

// === Memory ===
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

// === Revision control ===
define( 'WP_POST_REVISIONS', 5 ); // Limit revisions to prevent DB bloat

Production — Silent Logging Configuration

// === Debug (Production) ===
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );      // Log errors silently
define( 'WP_DEBUG_DISPLAY', false ); // Never show errors on screen
define( 'SCRIPT_DEBUG', false );
// SAVEQUERIES should be false on production — significant performance impact

// === Security Hardening ===
define( 'DISALLOW_FILE_EDIT', true );  // Disable Theme/Plugin editor in Admin

Important: SAVEQUERIES = true stores every database query in memory. On a production site with real traffic, this measurably increases RAM usage and slows response times. Always disable it after debugging and never commit it to production configuration.

9. Recommended Settings by Environment

EnvironmentWP_DEBUGWP_DEBUG_LOGWP_DEBUG_DISPLAY
Local Developmenttruetruetrue
Staging Servertruetruefalse
Production (normal)falsefalsefalse
Production (active debug)truetruefalse

WordPress Hosting With Full PHP Error Log Access

AsiaGB Hosting supports multiple PHP versions, includes phpMyAdmin, File Manager, and DirectAdmin — everything you need to debug and develop WordPress effectively. Starting at 500 THB/year.

View Hosting Plans →