How to Enable Debug Mode in WordPress (2 Methods)

WordPress is a powerful and versatile content management system, but like any software, it can encounter issues from time to time. When you’re facing technical problems with your WordPress website, enabling debug mode can be a helpful tool to diagnose and troubleshoot errors.

In this guide, we’ll walk you through the steps to enable debug mode in WordPress and make your debugging process more efficient.

What is Debug Mode?

Debug mode is a WordPress feature that offers detailed information about errors, warnings, and notices in your website’s code. When turned on, it shows these notices on the screen, making it easier to identify issues that could otherwise go unnoticed.

Debug mode is a valuable tool for developers and website administrators, as it allows them to enhance the overall quality and performance of a WordPress site.

Why Use WordPress Debug Mode?

Enabling WordPress debug can be particularly useful in the following scenarios:

  • Identifying PHP Errors: Debug mode helps you find PHP errors in your code that may be hidden in the default mode. It provides specific error messages, making it easier to find and fix issues.
  • Plugin or Theme Compatibility: Debugging can reveal if certain plugins or themes are causing conflicts on your site. By addressing the problem, you can take the necessary steps to resolve it.
  • WordPress Core Issues: Sometimes, core WordPress files may encounter errors. Debug mode can help you determine if there are problems in the core code that need attention.

That said, let’s look at how to enable the WordPress debug mode.

How to Enable Debug Mode in WordPress (2 Methods)

In WordPress, there are two ways to enable debug mode. Whatever method you use, keep in mind that you should always disable debug mode when you’ve finished troubleshooting.

WordPress debug mode will show PHP error codes on the front and back ends of your site, making them visible to visitors. Malicious hackers can take advantage of this information. Furthermore, it may cause users to be concerned about the safety of your website.

With that said, here are two methods to turn on WordPress debug.

Method 1: Enable Debugging Using a Plugin

If your web hosting service provider does not provide you with a specific link to enable WordPress to debug mode, you may always use WordPress plugins that help you enable debug mode. However, thousands of WordPress plugins are available, making it difficult for users to choose the perfect one.

As a result, for your convenience, we suggest that you use the WP Debugging plugin.

First, install and activate the WP Debugging plugin. For more details, see our guide on how to install a plugin in WordPress.

Upon activation, it will start working immediately. The plugin will set the following values to true in your wp-config.php file without your intervention:

define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'SCRIPT_DEBUG', true ); define( 'SAVEQUERIES', true );

All errors, notices, and warnings will be stored in a log, which you can view by clicking the Debug Quick Look link in your admin toolbar:

Debug Quick Look Feature in WP Debugging Plugin

When you’re done debugging, deactivate the plugin to restore your website’s pre-existing constants.

Method 2: Enable Debugging Without Plugin

You can also enable WordPress to debug mode by adding a code snippet in your wp-config.php file. The sole reason to use this method is if you want to limit the number of WordPress plugins you have installed.

Note: Before you start editing your wp-config.php file, we strongly advise backing up your website first.

There are so many backup plugins available, but the UpdraftPlus plugin allows you to upload your work to different cloud storage sites.

Once you’ve got a recent site backup, you can start editing your wp-config.php file.

Go and open the wp-config.php file and paste the following lines of code just before the line ‘/* That’s all, stop editing! Happy publishing. */’.

// Enable WP_DEBUG mode define( 'WP_DEBUG', true); // Enable Debug logging to the /wp-content/debug.log file define( 'WP_DEBUG_LOG', true);

By following these steps, you’ll be able to enable debug mode and save your errors to a debug.log file.

Once you’ve finished with the debug mode, repeat the steps for enabling it, but this time, remove or change the previously added code as follows:

// Disable WP_DEBUG mode define( 'WP_DEBUG', false);

Some Tips For Debugging Problems in WordPress

Apart from using WP DEBUG mode to find an error on your WordPress site, there are also some useful tips and tricks you may use to debug problems in WordPress.

For example, if your WordPress site crashes or displays a white screen of death. The most common debug solution for this problem is to disable your plugins and themes and check for updates. This method will help determine the actual cause of the problem, but it might be time-consuming. Furthermore, there’s a high possibility you won’t be able to detect the real issue.

As a result, you’ll need to use the correct tool to figure out what’s causing the error and fix it as soon as possible.

1. Enable WordPress Database (WPDP) Error Reporting

By enabling WPDP in your WordPress, you can also detect and identify any problems with the WordPress database. $show_errors is a variable in the $wpdb object that allows you to see all database errors. If you set this variable to true, all SQL errors will be displayed for any query.

var $show_errors = true; /** to show SQL/DB errors */ var $suppress_errors = false; /** to suppress errors during the DB bootstrapping. */

To activate WPDP error reporting, navigate to your public_html file and locate the wp-dp.php file within the wp-includes folder. Open the database file and look for the wpdb class to set the $show_errors variable to true.

2. Lookout Your Website’s Complete Error logs

Sometimes, you may encounter an internal server error page while browsing the website. The best thing you can do to fix this issue is to check your website’s complete error logs.

Simply reviewing your website’s complete error logs might be very helpful in identifying the likely culprit. If you do not know how to fix it after finding the likely culprit, a quick Google search will give you all available options.

3. Enable SCRIPT_DEBUG Mode

WordPress uses CSS and JavaScript files to improve website performance and loading time. However, these javascripts may contain hidden error codes that cause issues for your website.

So, to eliminate such problems with script execution, WordPress provides you with a constant that you can add to your wp-config.php file.

Go and open the wp-config.php file and paste the following lines of code just before the line ‘/* That’s all, stop editing! Happy publishing. */’.

define('SCRIPT_DEBUG', true);

When the script debugs option is enabled, WordPress will use the full version of all plugins and the development version of CSS and JavaScript files instead of the compressed versions.

4. Use a WordPress Staging Platform

A staging platform, often known as an exact copy of your live website, is hosted on a subdomain of your website. This clone website will act as a testing and development platform, allowing you to add codes and run tests before launching the live version.

Furthermore, this staging site will not be visible to any of your website visitors, and search engines will also not be able to find it. As a result, it gives you a complete environment to conduct experiments with no limitations and without affecting your live website.

Conclusion

Enabling debug mode in WordPress is an important skill for website owners and developers to have. It lets you easily identify and address issues, resulting in a more smooth and error-free WordPress experience. You can find and fix problems using the information in the debug.log file, ensuring that your site functions smoothly.

Remember to turn off debug mode once you’ve solved the issues to keep your site’s log files tidy and organized. Happy debugging!

For more, check out these other helpful resources:

Lastly, follow us on Facebook and Twitter to stay updated on the latest WordPress and blogging-related articles.