How to enable debug mode to troubleshoot WordPress

WP-DEBUG is a WordPress constant that lets you enable debug mode and display error messages on your site. It is very useful while you are developing on WordPress or fixing errors, because it helps you identify the cause of the problems you run into.

To enable WP_DEBUG, edit the wp-config.php file in the WordPress root directory. You can reach this file over FTP or through your web server's file manager.

In the wp-config.php file you will find the following line:

define( 'WP_DEBUG', false );

Change the value false to true to enable WP-DEBUG. After the change, the line will look like this:

define( 'WP_DEBUG', true );

Save wp-config.php. WP_DEBUG is now enabled.

If that line is not in wp-config.php yet, you can add it below the “<?php” line

Note: when you enable WP-DEBUG, error messages are displayed to every user who visits your site. This can affect both the user experience and the security of the site. You should therefore use WP-DEBUG only when necessary and turn it off when it is no longer needed.

For example: suppose you are installing a new WordPress plugin and hit the following error:

Fatal error: Cannot redeclare some_function() (previously declared in /home/user/public_html/wp-content/plugins/old-plugin/old-plugin.php:12) in /home/user/public_html/wp-content/plugins/new-plugin/new-plugin.php on line 15

This error means your new plugin contains a function with the same name as one in an older plugin. That causes a conflict and takes your site offline.

With WP-DEBUG enabled you can see exactly where the error is and fix it by renaming the function or removing the outdated plugin.

Similar Posts