Special offer: save $60 today

Unmasking errors: Guide to enable debugging in a WordPress website

4 minute read

In this article, we’re going to embark on a journey to demystify how to enable WordPress debug. Whether you’re a seasoned website developer or a novice blogger, this comprehensive guide is designed to be an accessible primer on debugging for everyone in the WordPress universe.

What is WordPress debugging?

Before we delve into the technicalities of debugging, let’s take a moment to understand what we’re referring to when we say “WordPress debug”. Debugging in WordPress is a way to uncover any errors, discrepancies or issues that might have gone unnoticed in your website’s backend. This feature will come in handy whether you’re testing a new theme, working on a plugin, or just carrying out routine maintenance.

How to enable debugging in WordPress

Let’s jump straight into the heart of the matter: how do you enable debugging in a WordPress website?

1. Locate your wp-config.php file

To kickstart the WordPress debug process, you’ll first need to locate the wp-config.php file. This is the control center for your WordPress website and can be found in the root directory of your website. You can access it via an FTP client (like FileZilla), or through the File Manager of your hosting control panel.

2. Backup your wp-config.php file

Before making any changes, it’s a good practice to create a backup of your wp-config.php file. This is a critical file, and any mistake can bring your website down. By creating a backup, you can revert to the previous version if something goes wrong.

3. Enable WP_DEBUG

After backing up the wp-config.php file, open it and look for a line of code that says define( 'WP_DEBUG', false );. This line is responsible for enabling or disabling the WordPress debug feature.

To enable debugging, replace false with true, making the line read define( 'WP_DEBUG', true );. Then, save and upload the file back to your server. Your WordPress site is now in debug mode, and PHP errors, notices, and warnings will be displayed on your site.

4. Enable WP_DEBUG_LOG and WP_DEBUG_DISPLAY

WordPress also provides additional debugging features: WP_DEBUG_LOG and WP_DEBUG_DISPLAY.

WP_DEBUG_LOG tracks all errors and saves them in a debug.log file located in the wp-content directory. To enable it, add the following line of code below your WP_DEBUG line: define( 'WP_DEBUG_LOG', true );.

On the other hand, WP_DEBUG_DISPLAY controls whether debug messages are shown inside the HTML of pages or not. You can disable it by adding define( 'WP_DEBUG_DISPLAY', false );. This will prevent errors from being displayed on your live site, while still being logged in the debug.log file.

5. Enable SCRIPT_DEBUG

If you’re having trouble with your site’s JavaScript or CSS, WordPress has a tool called SCRIPT_DEBUG. When this feature is enabled, WordPress will use the development versions of core CSS and JavaScript files instead of the compressed versions. To turn it on, insert the following line in your wp-config.php file: define( 'SCRIPT_DEBUG', true );.

Roundup and security recommendations

Having enabled WordPress debug and any additional tools, you’ll now be able to identify, address, and resolve potential issues affecting your website’s performance.

However, it’s of paramount importance to remember that once your debugging is complete, you should

disable these debug settings. Leaving your WordPress site in debug mode can expose vulnerabilities to potential hackers and disrupt the user experience, as the error messages will be visible on your live website. Therefore, when you finish, return to your wp-config.php file and revert the changes, or upload your backed-up file from earlier.

To disable WP_DEBUG, simply change true back to false in the define( 'WP_DEBUG', true ); line, making it define( 'WP_DEBUG', false );. Remember to do the same for the WP_DEBUG_LOG, WP_DEBUG_DISPLAY, and SCRIPT_DEBUG if they were enabled.

Once you’ve finished these steps, your WordPress site will be back to normal operating mode, but now with the potential issues identified and hopefully resolved.

Further debugging techniques and tools

While the above methods are native to WordPress, there are several other external tools and plugins available for debugging WordPress sites. These tools can help provide a more user-friendly interface and additional features, especially useful for those who are not comfortable dealing with code directly. Some of these tools include:

  1. Query Monitor: This is a developer tool panel for WordPress. It enables debugging of database queries, PHP errors, hooks and actions, block editor blocks, enqueued scripts and stylesheets, HTTP API calls, and more.
  2. Debug Bar: This plugin adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.
  3. Log Deprecated Notices: This plugin logs the usage of deprecated files, functions, and function arguments. It identifies where the deprecated functionality is being used and offers the alternative if available.

Keep in mind that while these tools can enhance the debugging process, they should only be used in a staging or development environment and not on a live site, as they can potentially reveal sensitive information to visitors.

Final thoughts

The process of enabling WordPress debug may seem daunting at first, especially if you’re new to website management. However, it’s an essential skill for maintaining a robust, error-free website. This in-depth guide should have equipped you with the knowledge to confidently enable WordPress debug and leverage its power to keep your website running smoothly.

Remember, debugging is not just about fixing issues; it’s also a journey of understanding the intricacies of your website, a process that, over time, will make you more skilled and competent in managing your WordPress site. Happy debugging!

Build your high-conversion WordPress forms

Take a look at our three different plans and learn how Happyforms can help you get the most out of all of your WordPress website traffic today.

Discover Happyforms for WordPress