There is no such thing as perfect code, and every webmaster's nightmare comes with a slow website or plugin error. Today, we will show you how to debug WordPress that will help you solve problems that are happening on WordPress.
What does debugging mean?
Debugging, or in short, debugging means identifying and removing bugs or errors in the code. The final step of debugging is to check the code is correct and make sure the problem doesn't happen again.
This is mainly done by programmers. They use tools to debug and this process is common in the software and application development phase.
Debugging strategies during debugging include unit testing, code preview, and pair programming.
So before the code or software is published to the users, the developer will try to find the problem, then isolate and fix it.
Sometimes, fixing code can be a real headache, as it can take longer than writing the code.
7 WordPress debugging tips
When a WordPress site crashes or gets a white screen of death (WSoD), a common fix is deactivating the plugin/ theme and checking for updates again.
Although this helps narrow down the cause. This can be time-consuming, inefficient, and you can also ignore the real problem. That's why the right tools can be worthwhile.
1. Enable WP_DEBUG
Enabling WP-DEBUG is probably the simplest way to log crashes on a WordPress site. But unfortunately, some developers don't do this, most likely because they forgot this feature exists.
WP_DEBUG is a constant that enables the “debug” mode in WordPress. You can find it in the wp-config.php file. This log can record all the activities on the website and help you to troubleshoot any problems.
2. Enable WPDP Error Reporting
To detect any database-related problems, you can enable WPDP error reporting.
The global $wpdb object has a variable called $show_errors . And if you set it to true, you can make WordPress output SQL errors to the screen.
To enable this, go to /public_html/wp-includes/wp-db.php and open the file. Search for wpdb class and change the $show_errors variable to true.
3. Check Error Logs on Website
Occasionally, you may encounter a server error page while browsing the web. And to troubleshoot such problems, you can review your website error logs.
Checking the general log will help both newbies and developers spot page issues.
4. Use WordPress Staging Environment when tweaking code
If you want to minimize bugs on your WordPress site, you can deploy the code first on your staging website.
A staging website is almost an exact replica of your running website. It can be hosted on its own private subdomain so as not to affect the commercial version. This site acts as a code testing platform, and you can push it to the official website when it's done.
This environment is mainly not visible to visitors and search engines. So you are free to tweak, improve and test the changes you want. As a result, you will not affect the running pages.
5. Enable SCRIPT_DEBUG
By default, WordPress uses minified versions of CSS and JavaScript files to help improve website load times. However, this can be a problem as it can hide errors in the scripts/plugins you use.
To change script execution, WordPress also provides a constant that we can add to the wp-config.php file, that is:
define ( 'SCRIPT_DEBUG' , true );
When the value is set to true, WordPress will automatically load the non-minified versions of all CSS and JavaScript files, making the plugin use the full version.
6. PHP Error Detection
You can detect PHP errors in your scripts early with phpinfo. This file can output information about the current state of PHP. These include a compiler, extension, version, environment, OS version, HTTP headers, and license options.
To do this, you can configure the php.ini file to enable error reporting. However, some hosting services, including Bluehost‘s shared hosting plan, disable this option.
That's because you don't have root access to enable this feature.
However, you can use a PHP code checker instead. It supports the simple to look for errors in the code. And for a more thorough evaluation, you can also use IDEs like Eclipse or PHPStorm.
7. Leverage Some Debug Tools
If you need simplicity when tracking errors on your WordPress site, use WordPress debugging plugins.
1. Query Monitor
This plugin provides a developer tool panel on WordPress. You can enable database queries, PHP errors, HTTP API calls, hooks & actions, stop editor blocks, enqueued scripts & stylesheets, etc.
Alternatively, you can also use the Debug Bar and Simply Show Hooks to debug your WordPress site. However, these two plugins may have compatibility issues with the latest WordPress version.
2. New Relic

You can also use a more powerful WordPress debugging tool with the Premium tool New Relic. This application helps you to monitor user experience, map WordPress architecture, analyze and improve site performance, and detect anomalies before it happens.
All of those features will help you collect data for troubleshooting. It helps you give your visitors the best possible experience. You can try New Relic for free for 14 days.
Conclusion
Those are all the tips you need to know about debugging WordPress websites. As a developer, you need to identify and fix issues before pushing any code/plugins to users. As a webmaster, you can also use debugging tools to determine what's causing your site's performance problems.
To debug a WordPress site, you can do the following:
- Enable WP_DEBUG
- Enable WPDP Error Reporting
- Check Error Logs on Website
- Use WordPress Staging Environment when tweaking code
- Enable SCRIPT_DEBUG
- PHP Error Detection
- Use a Debugging Tool like Query Monitor or New Relic
Good luck with your WordPress debugging. We hope you can minimize issues to ensure a seamless visitor experience.