How to Enable WP_DEBUG in WordPress (Step-by-Step)

Here is How to Enable WP_DEBUG in WordPress, you need to edit the wp-config.php file located in the root directory of your WordPress installation.

Step 1: Access wp-config.php

  • Use FTP (like FileZilla), cPanel File Manager, or your local file system.

  • Locate the wp-config.php file in the root folder (same place as wp-admin, wp-content, etc.)

Step 2: Add or Update the WP_DEBUG Code

Find this line in the file:

php
/* That's all, stop editing! Happy publishing. */

Add the following code just above it:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true); // Optional: Save errors to a debug log
define('WP_DEBUG_DISPLAY', true); // Optional: Show errors on the screen

This will:

  • Enable debugging (WP_DEBUG)

  • Log errors to a file (debug.log)

  • Display errors directly in the browser (WP_DEBUG_DISPLAY)


Where Is the Debug Log File?

If you use WP_DEBUG_LOG, all errors will be saved to:

lua
/wp-content/debug.log

You can open it with any text editor to review recent errors and warnings.


Hide Errors from Public View (Optional but Recommended)

Sometimes, especially on a shared server or public demo, you might want to log errors silently—without showing them on screen. In that case, use this setup:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

This allows you to debug behind the scenes without scaring off users or leaking information.


What Happens if You Leave WP_DEBUG Enabled?

Leaving WP_DEBUG on a live site is risky:

  • Users might see raw error messages

  • Hackers could exploit exposed paths and vulnerabilities

  • It looks unprofessional to clients or customers


đź§© When to Turn It Off?

After you’ve:

  • Fixed the issue

  • Deployed updates

  • Completed theme/plugin development

Simply revert this line:

php
define('WP_DEBUG', false);

And make sure logging and display are also turned off.


Conclusion

Enabling WP_DEBUG is one of the most powerful tools WordPress developers have for identifying and fixing bugs. Just remember to use it wisely—only in a safe, non-public environment—and turn it off before going live.


FAQs:

What is WP_DEBUG in WordPress?

WP_DEBUG is a PHP constant used to turn on the built-in debugging mode in WordPress. When set to true, it shows PHP errors, warnings, and notices, which can help you identify issues during development or troubleshooting.


Where is the WP_DEBUG setting located?

You’ll find the WP_DEBUG setting in your WordPress wp-config.php file. It’s located in the root directory of your WordPress installation, alongside folders like /wp-content/ and /wp-admin/.


How do I enable WP_DEBUG in WordPress?

To enable WP_DEBUG, open wp-config.php and add the following code before the line that says /* That's all, stop editing! */:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);

Where can I find the debug log file in WordPress?

If you’ve enabled WP_DEBUG_LOG, WordPress will create a log file at:

lua
/wp-content/debug.log

You can open it using any text editor to view recent error logs.


Can I enable WP_DEBUG without showing errors to visitors?

Yes. Use the following configuration to log errors silently without displaying them in the browser:

php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

This way, errors are saved privately in debug.log without affecting user experience.


Is it safe to keep WP_DEBUG enabled on a live site?

No. Keeping WP_DEBUG enabled on a production/live site is not safe. It can expose sensitive error messages to visitors or hackers, potentially revealing file paths or vulnerabilities. Always disable it when not in use.


When should I enable WP_DEBUG?

Enable WP_DEBUG when:

  • You’re developing a theme or plugin

  • You’re fixing a bug or error

  • You’re working in a staging or local environment

  • You need more visibility into what’s breaking your WordPress site


How do I know WP_DEBUG is working?

Once you enable it and trigger an error (e.g., a faulty plugin), you should either:

  • See error messages on the screen (if WP_DEBUG_DISPLAY is true)

  • Or find entries inside /wp-content/debug.log

If neither happens, double-check that your changes to wp-config.php were saved correctly and placed before the /* That's all, stop editing! */ line.


Follow Marketist Blog to stay updated on WordPress

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top