To activate WordPress debug mode, simply change the config text string to this:
define( 'WP_DEBUG', true );
This will cause all PHP errors, notices, and warnings to be visually displayed on your website. Sometimes, the errors identified may seem benign or trivial, indicating that they don't follow PHP data-handling conventions or other rules. Remediating these issues isn't necessary but can help reduce total code size and improve website functionality.
In other cases, PHP errors may be related to code conflicts or outdated functions that hamper website performance and may eventually cause your site to crash.
Your Top WordPress Debug Questions Answered
Got questions? We have answers about using the WordPress debug mode. Here's what you need to know.
1. What’s the best way to enable WordPress debugging?
Wondering, how do you enable debug mode in WordPress? There are three strategies you can use to do so.
Enable it directly from WordPress PHP code
As noted above, this requires modifying the wp-config.php file to activate debugging mode and display errors. While it's not a complicated change, it's not recommended if you're uncomfortable with PHP programming and WordPress PHP code.
Through your hosting provider
Many hosting providers allow site owners to activate WordPress debugging mode directly from website admin consoles within the hosting platform. While the format varies from provider to provider, it's worth checking here before modifying PHP code directly.
With the help of a third-party plugin
Plugins are one reason for the massive success of WordPress — rather than take on the task of adding every function directly, WordPress developers have made it possible for developers to create plugins that perform specific actions when tied into CMS deployments, so long as these plugins meet WordPress code guidelines. Plugins offer the easiest way to activate WordPress debug mode and often come with additional features to help track and monitor errors.
Worth noting? No matter how you activate WordPress debugging mode, it's best used on sites that are in development or deployed on testing servers. For example, if you're currently building a WordPress site or developing a new WordPress plugin, it's worth using debug mode to identify and remediate potential errors before going live. By learning how to debug WordPress in these scenarios, you can save yourself invaluable time and energy.
And when you're doing debugging — either to fix specific errors or evaluate site performance — always remember to turn WordPress debugging mode off again.
2. Should I use the WordPress debug log?
While activating WordPress debug mode will display code errors, it won't save these errors for future reference. Activating the WordPress debug log allows any errors to be saved in the wp-content/debug.log found in your site's file system. To activate the debug log, this code must be present in the wp-config.php file:
define( 'WP_DEBUG_LOG', true )
3. What WordPress debug plugins are available?
There are a host of WordPress plugins to help manage debugging mode. Two of the most popular are Query Monitor and Debug Bar; both allow you to easily activate the debugging mode in WordPress and offer additional features.
In the case of Query Monitor, debugging capabilities are extended to include Ajax calls, REST APIs calls, and user capability checks. Debug Bar, meanwhile, adds a debugging menu to the WordPress admin bar that displays query, cache, and additional debugging information at-a-glance to streamline the process.
4. Are there any risks to debugging WordPress?
While activating WordPress debug mode allows site owners to track down specific issues and test new deployments for compatibility before live release, it does introduce potential risks that you should keep in mind when learning how to debug WordPress sites.
The main concern is security. When the debugging mode is activated on live sites, malicious actors can access underlying code operations. If they can then compromise administrative environments, they may be able to insert new code which allows them to exfiltrate site data or install digital "backdoors" that enable long-term access.
Why Debugging WordPress Matters
WordPress sites are designed for streamlined operation and simple modification using approved third-party plugins and tools. But things don't always go as planned — if you're building your plugin or designing a WordPress website from the ground up, you may encounter code conflicts that could negatively impact performance or even cripple sites at scale. That's why learning how to debug WordPress websites is so wise.
WordPress debugging mode makes it possible to identify these issues before your site, or service goes live, in turn reducing the time and effort required to find and fix potential problems.
Editor's note: This post was originally published in December 2020 and has been updated for comprehensiveness.