No one starts off programming with a love for debugging. It is a source of endless frustration and dread. A lot of you wonder how many hours you would have to spend debugging. You’d much rather spend time building something cool.

That said, a good developer will never consider debugging as unimportant. It is an invaluable source of learning and growth. But debugging in the absence of a supporting environment is a developer’s nightmare. Thankfully, WordPress does provide efficient mechanisms to make debugging easy.

This article is about enabling WordPress debug tools. It’ll help you fix issues faster.

But before we get into the thick of things, for the uninitiated, here’s a short paragraph on what debugging means in the context of WordPress sites.

What is WordPress Debugging?

Debugging is the process of searching and removing errors from a piece of code.

While writing code, the developer makes mistakes just like you’d make spelling and grammatical mistakes when typing out an email. In the coding world, going back and correcting those faults is called debugging.

WordPress offers an easy way to debug faults and errors made by plugin and theme developers. But the debugging is disabled by default. You can enable it to fix malfunctions, incompatibility issues, etc. Let us show you how.

WordPress offers an easy way to debug faults and errors made by plugin and theme developers. Click To Tweet

 

How To Enable or Disable Debugging in WordPress?

Before you begin…

For debugging in WordPress, you’ll need to edit WordPress files. That’s risky. One fatal error could cause your website to break. It’s best to take a complete website backup so that you can restore your site back to normal when something goes wrong.

To enable or disable WordPress debugging, you’ll make edits in the wp-config.php file. Be careful with the file because it is one of the most important files on your website. It’s used to improve security, enhance performance, configure database functionalities, among other things. Making the slightest of mistake could make your website inaccessible (recommended read – Securing wp-config File).

Enable or Disable Debugging Mode Manually

To enable debugging mode in WordPress, follow these steps:

1. Log into your hosting account and launch File Manager.
2. In the public_html folder, find and open wp-config.php.
3. In the wp-config file, you’ll find the following line of code –

define(‘WP_DEBUG’, false);

The WordPress debug mode is now disabled. To enable it, you’ll have to replace ‘false’ with ‘true.’ It looks like this –

define(‘WP_DEBUG’, true);

Save the changes and exit the editor.  You have now enabled WordPress debugging mode.

 

enabling WordPress debug mode

Debugging mode is now enabled

To disable the mode, all you have to do is change ‘true’ to ‘false.’

There are more WordPress debugging options with which you can resolve many issues. Let’s looks at those options.

Enable or Disable Debugging Mode With a Plugin

There are many plugins in the market that make debugging WordPress really easy for you, WP Debugging is one such plugin. It will automatically set the debugging options to true.

To disable the settings, just deactivate the plugin.

 

deactivating debug plugin

WP Debugging dashboard

 

Other WordPress debug plugins that you can try out are Query Monitor, Debug Bar, and Log Deprecated Notices.

Additional WordPress Debugging Options

To make the process of debugging more efficient, WordPress offers a few other options. You can enable them whenever required. Here’s how to access additional debugging options offered by WordPress –

To Examine Errors On Your Site

If you’ve been using WordPress for a long time, you must have come across the White Screen of Death! It’s when your website shows blank pages. This is an error that is caused by a fault in the code among other things.

A WordPress website makes a note of such errors and stores them in a file. Luckily, you can access the debug logs by placing the following code in wp-config.php:

define(‘WP_DEBUG_LOG’, true);

Note: To get the WordPress debug logging file, you’ll have to have the WP_DEBUG set to true.

After saving the code, head over to your hosting provider account and launch your File Manager. The log file is typically present under the public_html folder.

Decompressing Files & Checking Errors

From search engines to visitors, everyone hates slow websites!

To make websites run faster WordPress compresses certain files to reduce the size of the files. In the process, some files are hidden which becomes a pain when developers are looking for an php error to debug an issue.

So what you need to do is decompress the files by adding the following script to your wp-config file:

define( ‘SCRIPT_DEBUG’, true );

To Prevent Displaying Errors On Your Site

When you are debugging a WordPress website, error and warning messages appear on your website. But the error messages could make your website look like it’s broken and reliable. If you want to ensure that those messages are not appearing on your website disable the option.

Place the following code in the wp-config file:

define( ‘WP_DEBUG_DISPLAY’, false );

Note: For the above code to work, you’ll have to have the WP_DEBUG set to true.

To Examine WordPress Database Errors

WordPress stores all your website content in a database. If a website is experiencing database issues, you can enable a setting that will help you identify those issues.

Add the following code to your wp-config.php file:

define( ‘SAVEQUERIES’, true );

Setting the ‘SAVEQUERIES’ to ‘true’ will enable you to send a database query in order to access the information stored in it.

Note: You can’t enable SAVEQUERIES, if you didn’t set WP_DEBUG to true.

 

enable savequeries in wordpress debug

Enabling all of WordPress debugging options

 

With that, we have covered all the options WordPress offers to help developers debug WordPress issues on a WordPress website. But before winding up, there’s one important thing to consider.

Taking notes is not everyone’s cup of tea. But experience tells us that in the world of coding when a problem occurs, it’s very likely to reoccur. Maintaining a solution log makes it easy as well as fast to find a solution to a problem that is reoccurring.

Conclusion

While debugging is not something many developers enjoy doing, it’s an important piece of work. The good news is that WordPress provides a support environment to perform debugging. The bad news is that debugging WordPress often has an impact on your website performance. It’s best to avoid doing it on live sites and use a staging website instead.