WordPress

WP_DEBUG

WP_DEBUG is the PHP constant in wp-config.php that switches WordPress into debug mode, showing or logging notices, warnings, and deprecated calls that are normally hidden.

How it is measured

Set define( 'WP_DEBUG', true ) to turn it on. Its companions are WP_DEBUG_LOG to write to wp-content/debug.log, WP_DEBUG_DISPLAY to print on the page, SCRIPT_DEBUG to load unminified core scripts, and SAVEQUERIES to record every database query. The constant is checked on every request, so it changes behavior immediately.

Verify the effect by triggering a known notice, for example reading an undefined array key in a test plugin, and checking the log. wp config get WP_DEBUG prints the current value.

Worked example

A developer turns on WP_DEBUG on the live site to find a blank page and leaves display enabled. A visitor sees Warning: Undefined variable in /home/acme/public_html/wp-content/themes/acme/header.php on line 14 at the top of the homepage, and the absolute path is now public.

The warning also prints before the headers, so a redirect later in the request fails with Cannot modify header information. The developer switches to WP_DEBUG_LOG with display off.

How it differs

WP_DEBUG is the constant that enables reporting, and wp-config.php is the file where you set it. The log file is a separate decision. Turning WP_DEBUG on makes WordPress surface deprecations from plugins that run fine today, so it is a development setting, not a health check you leave on.

Common errors

Leaving display on in production. Setting WP_DEBUG after the line that loads wp-settings.php, so it is ignored. Turning it on with a page cache and wondering why nothing changes. Ignoring deprecation notices until a PHP upgrade turns them into fatals. Posting the output with server paths in a public forum.

In practice

Use it on staging with logging on and display off. Fix notices from your own code, report the ones from plugins to their authors, and set it to false before you finish. Check Site Health for any debug settings left on.

See also

wp-config.php, debug.log

Sources

Count this on a real site.

Watch my website