How to Use WP_DEBUG

Updated on Oct 3, 2019

If you turn on WP_DEBUG on your WordPress website, it will give you a much better understanding of what is going on, especially in the event of an issue. Additionally, enabling WP_DEBUG is beneficial for all theme and plugin developers that require their products to be promoted publicly by WordPress.

In this post, we will cover everything essential about WP_DEBUG and all the ways you can make use of it for the development of your WordPress site.

You will find:

Reasons to Enable WP_DEBUG

WP_DEBUG is a PHP constant. It is created with the purpose of triggering the WordPress debugging mode. You will be able to find that mode inside your wp-config.php file. By default, the mode is disabled, but you can do many crucial tasks with it after you enable it. The main reasons to enable it are:

  • WP_DEBUG will give you essential information about how to reproduce a specific issue. Via saving a log file, WP_DEBUG records all activities that happen on your website, which can help in troubleshooting a problem;
  • WP_DEBUG would display a deprecated functions list in all theme and plugin releases. Those are functions to be marked as inactive in the future. The notification would often let you know that there are alternatives to those functions and what exactly they are;
  • Debugging mode comes whenever you want to build a plugin or theme. WordPress Codex encourages all developers to use WP_DEBUG when they work on their products. This would help other developers see when there are problems and warnings, which ultimately benefits everyone save time. If a plugin or a theme is not compatible with WP_DEBUG, the WordPress tool library is not going to endorse them.

Practical Use of WP_DEBUG

After we have explained the general idea of what exactly WP_DEBUG is, let’s go over its practical uses.

WP_DEBUG

The WP_DEBUG mode can be found in the wp-config.php file. By default, the file’s value is set to false.To enable it, you need to make it true. For that, you have to use an FTP client such as FileZilla or a File Manager (via cPanel) to access the file.

In this example, we are going to use the File Manager in cPanel (my.fastcomet.com → cPanel → File Manager).

When you are in the File Manager, in the root folder of your WordPress site, you need to find your site’s wp-config.php file (public.html/wp-config.php):

  • Open wp-config.php and then search for
define( 'WP_DEBUG', false )
  • Once located, rewrite false to true
define( 'WP_DEBUG', true )
  • Then, save the file.

If you are unable to find the code in the site’s wp-config.php file, you are able to add it above the line that says /* That’s all, stop editing! Happy blogging. */.

Keep note that the debugging mode should not be enabled on a live website because it is designed specially and only for development purposes.

WP_DEBUG_LOG

Enabling WP_DEBUG_LOG gives users the option to save all errors in a debug.log file. The function is working perfectly with WP_DEBUG while also helping reproduce issues for troubleshooting.

To enable WP_DEBUG_LOG, you need to open your wp-config.php file and then under define( ‘WP_DEBUG,’ true ), enter the following:

define('WP_DEBUG_LOG', true)

After you have the function, the debug.log file would be saved automatically in the wp-content folder of your WordPress site. You will be able to view the file directly in your browser.

WP_DEBUG_DISPLAY

WP_DEBUG_DISPLAY is a function that needs to be disabled. That is to prevent error messages from being displayed on your WordPress website. By default, each time there is an error, it would be generated and displayed inside the HTML code of your site. Unlike WP_DEBUG, the default value of WP_DEBUG_DISPLAY is set to true and needs to be changed to false in order to hide all the errors.

In case WP_DEBUG_DISPLAY is not available, you have to add a line of code in the wp-config.php file. Do that below the define(‘WP_DEBUG,’ true). The code line to insert is:

define('WP_DEBUG_DISPLAY', false)

All of the features we covered: WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY could be used at once. 

Conclusion

Understanding the proper use of WP_DEBUG has lots of essential benefits for WordPress site owners and developers. However, if you have any questions, or if you are having trouble using the WP_DEBUG mode, you can always open a support ticket and seek guidance from our 24/7 technical support team. They are ready to help you at any time. Also, if you are not yet a FastComet client, feel free to check our pricing list and decide if we are worth your attention.

We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!

WordPress Hosting

  • Free WordPress Installation
  • 24/7 WordPress Support
  • Free Domain Transfer
  • Hack-free Protection
  • Fast SSD Storage
  • Free WordPress Transfer
  • Free CloudFlare CDN
  • Immediate Activation
View More