How to Use WP_DEBUG?

Introduction

PHP is a well known programming language used by Wordpress having its own debugging mechanism. WordPress has some pre-defined debugging mechanisms like WP_DEBUG. The WP_DEBUG is a constant located in wp-config.php file of any wordpress based website.

 

When can we use the WP_DEBUG?

WP_DEBUG is very helpful to debug and identify unknown issues that starts appearing on your WordPress Websites. When WP_DEBUG is enabled, it will start throwing PHP notices, debug messages and deprecated function alerts in your WordPress website. By examining those errors & notices, you can easily identify and update required components of the WordPress or PHP. It is the most helpful function to identify the deprecated function in WordPress themes or WordPress plugins and to avoid the known issues of website hacking.

How can we use the WP_DEBUG?

 To turn on or enable the WP_DEBUG, you have to add the single line of code in wp-config.php file, which is as follows:

define('WP_DEBUG', True );

Enabling WP_DEBUG will fire some additional commands which will increase website load time. So,  it is advisable to keep it disabled unless you need it. By default, WP_DEBUG is disabled, "True" will use to enabled and "False" will use to disabled. 

How it works?

After enabling the WP_DEBUG, WordPress will start generating errors & logs and they will be recorded in debug.log file. The location of debug.log file is "wp-content" folder. You can explore this file to see the list of errors, logs & alerts of your WordPress blog.

It is also necessary to turn on the WP_DEBUG_LOG & turn off 'WP_DEBUG_DISPLAY' feature which will start saving all errors to a debug.log file.

define ( 'WP_DEBUG_LOG', true);
define ( 'WP_DEBUG_DISPLAY', false);

Disabling of WP_DEBUG_DISPLAY will start saving all these logs to your log file.

 

Precautions


If you're trying to debug something on your live site, use WP_DEBUG with "DISPLAY" feature "OFF". If this is not done, all the errors and notices will start appearing on the front-end and visible to your site visitors.

If the boolean values are not set in command  ('), it will be considered as 'true'. 

  • 54 Users Found This Useful

Was this answer helpful?

Related Articles

How to update your WordPress installation through one click update method?

How to update your WordPress installation This tutorial assumes you've already logged in to...

How to Upload a WordPress theme?

Sometimes you are required to upload and install a WordPress theme manually, especially when you...

How to Fix the 500-Internal Server Error in WordPress?

So you have been receiving 500 Internal Server Error in your WordPress website? Don’t panic, have...

How to Edit Your User Profile in a WordPress Blog?

How to edit your profile in WordPress This tutorial assumes you've already logged in to...

How to write a new post in WordPress

How to write a new post in WordPress This tutorial assumes you've already logged in to...