wp-config.php » How to enable WP_DEBUG in WordPress

How to enable WP_DEBUG in WordPress

WP_DEBUG option controls the reporting of some errors and warnings and enables use of the WP_DEBUG_DISPLAY and WP_DEBUG_LOG settings.

In this quick tutorial I will show you how to enable the WP_DEBUG feature and output the results to a log file.

Edit the wp-config.php file, find this line and change the value from false to true:

define( 'WP_DEBUG', true );
image 46 - How to enable WP_DEBUG in WordPress

TIP: You can also enable WP_DEBUG only for your IP and reduce harmful displays on a production site with the command (change 12.34.56.78 with your IP):

if ("12.34.56.78" === $_SERVER["REMOTE_ADDR"]) {
define( 'WP_DEBUG', true );
} else {
define( 'WP_DEBUG', false );
}

If you have WPCLI installed run the following to enable debug mode:

wp config set WP_DEBUG true
image 45 - How to enable WP_DEBUG in WordPress

Another handy option is the WP_DEBUG_LOG, which in combination to the WP_DEBUG option will save all error messages into a debug.log file located inside the /wp-content/ directory.

To enable debug.log file, add the following code to the wp-config.php file:

define('WP_DEBUG_LOG', true);

Afterwards open the /wp-content/debug.log file and view the errors.

NOTE: Database errors are printed only if WP_DEBUG is set to true. Database errors are handled by the wpdb class and are not affected by PHP’s error settings.

See also  Show the number of total 👁️ views for all posts inside a WordPress category

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended