How to Enable WordPress Debug Mode

In Wordpress on 2~4 minutes
How to Enable WordPress Debug Mode

Even though when there is an error in a WordPress site, it does not display any helpful information. Instead, it shows the WordPress WSOD (White Screen Of Death) page or a similar message which does not have any useful information about the error to fix the root cause. This happens because the WordPress debugging features have been turned off by default. But we can easily enable the WordPress debug mode.

First, open the wp-config.php file in the root directory of the WordPress installation by using FTP or SSH. Near the bottom of that file, you will be able to see define('WP_DEBUG', false);. Change it to true as below. It will enable the WordPress debug mode.

define( 'WP_DEBUG', true );

Still, we do not need to display debug information in the live site, so disable error displaying in pages with the following code.

define( 'WP_DEBUG_DISPLAY', false );

Since now errors are not visible anymore, put them into a log file. The following line will put all the debug information in the debug.log file which is in the wp-content directory.

define( 'WP_DEBUG_LOG', true );

Optional: Instead of creating the debug log file in the wp-content directory, you can use a custom directory path like this.

define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );

The following line will allow you to debug SQL queries, executed queries will be in $wpdb->queries. But it will degrade the performance of your site so make sure to disable it when not required.

define( 'SAVEQUERIES', true );

Add all these lines before the /* That's all, stop editing! Happy publishing. */ line in the wp-config.php file. Finally, altogether, it should be something like this.

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

/* That's all, stop editing! Happy publishing. */

If you are not familiar with this kind of file editing, simply install the WP Debugging plugin. It will do all these things for you without any manual file editing.

Share: