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'. 

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Migrate / Transfer WordPress Website from WordPress.com to AccuWeb Hosting?

To transfer your WordPress.com website to a self-hosted WordPress website, first you will need a...

How to manage plugins in WordPress

How to manage plugins in WordPress This tutorial assumes you've already logged in to...

Comparison between Free WordPress Hosting and Paid WordPress Hosting

AccuWeb Hosting provides free WordPress hosting and fully managed WordPress Hosting plans. There...

How to install theme in WordPress Website

What is a Theme and why we need it? Themes allow users to change the look and functionality of a...

How to configure WordPress to use temporary URL?

WordPress is a CMS application that can be installed and accessed through a domain name. As per...