The Complete Guide for WordPress Debugging (Enable WP_DEBUG + other tools)

Mar 23, 2022
WordPress debug

For you to do this, WordPress includes its own built-in debug mode , and there are also third-party programs to help troubleshoot WordPress.

In this post we'll explore the WordPress built-in WordPress debug mode. We'll show the steps to activate it. Then, we'll also share several other methods that you could troubleshoot your WordPress site.

We'll go over everything:

What Can WP Debug do?

If you're encountering issues on your website, WordPress debug mode can help you find out what's wrong, by displaying all PHP errors, notices, and warnings.

If you activate the debug option, you'll get the following messages whenever you encounter something wrong ( even if it's not creating immediate problems):

What's in What is WordPress Debugging Log?

When you enable WordPress debug mode in its own way You'll be able to see the same messages as the example above on your site at the moment - but those messages will not be saved to any place.

If enabled, when you set the WP_DEBUG_LOG constant to true, WordPress will write all issues to the following file:

  wp-content/debug.log  

However, you can also create a custom location to save the log file to a different location on your server.

If you want to save errors to the log but not publicly display them within the HTML on your page (like the screenshot example above) it is possible to utilize this WP_DEBUG_DISPLAY constant to allow debug mode to be enabled but do not display any messages on your site.

Typically, you'll want to mix WP_DEBUG_DISPLAY along with the WP_DEBUG_LOG.

How to enable WordPress Debugg Mode

To enable WordPress Debug Mode, there are a variety of choices. Three methods will be covered to enable this mode:

How to Enable WordPress Debug Mode in My

It is useful in having the ability to swiftly switch on debug mode, and then display messages on your website, but it doesn't let you decide whether to display what happens to the WordPress debug log, or even whether or not to display messages on live sites. If you want to use just the debug log it is possible to use to use the plugin in the next section.

To get started:

  • Open your My dashboard.
  • Choose the website on which you would like to enable debugging in the Sites List.
  • Visit click on the Tools tab in that site's dashboard.
  • Click Allow in the section WordPress debugging.

When you're finished, you can disable debug mode by clicking the button to disable the button located on the dashboard of your computer:

How do I Use the WordPress Debug Plugin

If you're hosting elsewhere , you can also find free WordPress debugging plugins that allow you to easily enable the debug mode. There are several options at WordPress.org however we suggest the WP Debugging free plugin from Andy Fragen.

After you have installed and activated the plug-in, it starts immediately. It defaults the following constants true(that is, it activates the features listed below):

  • WP_DEBUG - enables debug mode.
  • WP_DEBUG_LOG - saves messages to the log file.
  •    SCRIPT_DEBUG  
  •    SAVEQUERIES  

The last two constants do a little further down in this blog.

To configure a few options for your configuration, go to Tools - WP Debugging:

The settings are for the WP Debugging plugin
Settings for the plugin WP Debugging

Once you're finished, make sure to disable the plugin so that it is not in the debug mode.

Want to know the ways we have increased volume by more than 1000%?

Join 20,000+ others who receive our weekly newsletter that contains insider WordPress tips!

How do you manually enable WordPress Debug Mode

Finally, you can also activate WordPress debug mode manually adding the constants to the wp-config.php file.

To enable just the basic WordPress debug feature, you need to add this code snippet below the line which says /* That's all, put aside making edits! Happy blogging. */:

// Set up WP_DEBUG mode.
  define( 'WP_DEBUG', true );

It is also possible to use any of the following constants according to your preference:

// Enable Debug logging to the /wp-content/debug.log file
  define( 'WP_DEBUG_LOG', true );
 // Disable the display of warnings and errors.
  define( 'WP_DEBUG_DISPLAY', false );
  @ini_set( 'display_errors', 0 );

After you're done, you may set the constants to false or take the code out to turn off the debug mode.

Make Sure to Disable the Debug Mode within WordPress After you've finished

We mentioned this above - but this is just a reminder to always disable debug mode once you've completed solving your issue.

Alternative Methods of Debugging WordPress

Apart from the debugging tool built into WordPress that we have mentioned earlier Additionally, there are other built-in and third-party tools to help you debug your WordPress website.

Script Debug

This is useful when you're trying to test changes made to the included .js and .css files.

To enable SCRIPT_DEBUG, you can either:

  • Utilize the free WP Debugging plugin above. It is enabled automatically.
  • Add the following constant to your wp-config.php file - define( "SCRIPT_DEBUG", true );

Database query Debugging

  • Every query to the database.
  • The function which calls the query to the database.
  • How long the query took.

To enable query logging, you have two options:

  • Make use of the WP Debugging plugin mentioned above, that allows it automatically.
  • Include the following constant in the wp-config.php file - define( "SAVEQUERIES", real );

The Query Monitor Plugin

  • Database queries.
  • PHP errors.
  • Enqueued scripts and stylesheets.
  • The capabilities of the user.

It's a great tool overall. the top WordPress debug tools that you'll discover, and that's why it's almost 5 stars on more than 350 reviews.

Once you install and activate the plugin, you'll get some new options on the WordPress toolbar that display the debug info. Clicking on these options will open a new "Query Monitor" box, which provides additional information:

The Query Monitor plugin
The Query Monitor plugin

New Relic

Server Logs

Additionally, the logs of your server can also be a useful instrument for debugging WordPress.

If you host your site at  the server, you are able to view all of your server logs through the logs tab on a website's dashboard.

If you host on another server then you'll have to check your host's documentation to learn which locations you'll be able to view the logs of your server.

Summary

If you need to debug WordPress using the built-in WordPress debug mode offers a useful way to view PHP warnings and errors.

If you host your site at you can enable it right in your account. If not, you may enable the plugins, or even by adding code snippets to your site's wp-config.php file.

To get more assistance You can use additional built-in or third-party software like New Relic (your own license is needed) and the cost-free Query Monitor plugin.

Have you got any more questions about how to debug WordPress? Comment below and we'll get back to you!

Reduce time, money and maximize site performance with:

  • 24/7 help and support 24/7 support from WordPress hosting specialists, 24 hours a day.
  • Cloudflare Enterprise integration.
  • Reaching a global audience with 29 data centers around the world.
  • Optimization using the built-in Application to monitor performance.