WordPress Tutorial

What is WP DEBUG: A Comprehensive Guide

Turning on WP_DEBUG on your WordPress site can give you a better understanding of what’s happening on it, especially when there is an issue. It will also be beneficial for any theme or plugin developers who want their product to be publicly promoted by WordPress.

Therefore, in this article, we will show you everything you need to know about WP_DEBUG and how you can make use of it for your website’s development.

Why is WP_DEBUG Important?

WP_DEBUG is a PHP constant that triggers debugging mode in WordPress. You can find it inside your wp-config.php file. While this mode is disabled by default, you can do many important tasks with it once it’s enabled.

First, it will give you information about how to reproduce an issue. By saving a log file, it records all activities happening on your site and that can help to troubleshoot a problem.

Secondly, WP_DEBUG will display a list of deprecated functions in WordPress theme or plugin releases. These are functions that are marked as inactive in the future. This notification also often lets you know what alternatives can be used instead.

Another important reason for enabling debugging comes when you want to build a theme or plugin.

WordPress Codex highly recommends that every developer use WP_DEBUG when creating their product so that when there’s a problem or warning, another developer can inspect and fix the code.

If it isn’t compatible with WP_DEBUG, the official WordPress tool library won’t endorse your plugin or theme.

Practical Uses of WP DEBUG

Having explained the general idea of what WP_DEBUG is, now we are going to cover practical use.

WP_DEBUG

WP_DEBUG is located in the wp-config.php file and by default has the value set to “false”. If you want to enable it, you have to change it to “true”. To do so, you will need an FTP client, like FileZilla or a file manager to access the file.

In our example, we will use the Hostinger File Manager.

  1. Find the wp-config.php file in the root folder of your website. In our example, it is in hostinger-dev-9.xyz/public_html/wp-config.php.wp-config.php file location
  2. Open it and search for
    define( 'WP_DEBUG', false )

    How to enable WP_DEBUG

  3. Once located, change false into true. Then, save the file.

If there is no such code in your wp-config.php file, you can add it above the /* That’s all, stop editing! Happy blogging. */ line.

Keep in mind that debugging should not be enabled in a live website because this mode is designed for development purposes only.

WP_DEBUG_LOG

By enabling WP_DEBUG_LOG, users are able to save all errors in a debug.log file. This function works hand in hand with WP_DEBUG and can help reproduce problems for troubleshooting.

To enable it, open the wp-config.php file and enter this following line under define( ‘WP_DEBUG’, true );

define('WP_DEBUG_LOG', true);

How to enable WP_DEBUG_LOG

After you activate the function, the debug.log file will be automatically saved in the /wp-content/ folder of your website. You can directly view the file in your browser.

debug.log file location inside the WordPress directory

WP_DEBUG_DISPLAY

You should disable WP_DEBUG_DISPLAY so the error messages won’t be displayed on your website.

By default, every time there’s an error, it will be generated and shown inside your HTML code. And unlike WP_DEBUG, the original value is “true” and you have to change it to “false” to hide all errors.

Or if it isn’t available, you need to insert this line in the wp-config.php file just below the define(‘WP_DEBUG’, true); line.

define('WP_DEBUG_DISPLAY', false);

How to hide all errors by disabling WP_DEBUG_DISPLAY

All of these features: WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY can be used all at once to enable debugging, save a log file and hide all the errors.

Conclusion

Understanding how to use WP_DEBUG has many important benefits for WordPress site owners and developers alike. You can use it to enable debugging mode and save or hide all errors for better website development. What’s more, the process is actually pretty easy.

Here’s a summary of all steps to make use of WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY:

          • WP_DEBUG — Find the wp-config.php file and set define( ‘WP_DEBUG’, false ); to true.
          • WP_DEBUG_LOG — Add define(‘WP_DEBUG_LOG’, true); under the define(‘WP_DEBUG’, true); line.
          • WP_DEBUG_DISPLAY — Enter define(‘WP_DEBUG_DISPLAY’, false); under the define(‘WP_DEBUG’, true); line.

If you have any questions, just hit us up in the comment section down below!

About the author

Irfan F.

Irfan is a member of the Digital Content Writer team at Hostinger. He believes that technology and the internet can help improve our lives significantly. That's why he shares his experience as a WordPress blogger to educate others. In his free time, Irfan enjoys good films and books.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in WordPress Tutorial
6 Best WordPress Theme Detectors
Close