How to Debug WordPress Website

WordPress, the world’s most popular content management system, is powerful and flexible. But, like any technology, it can occasionally run into problems. In this article, we’ll guide you through debugging WordPress, helping you identify and resolve issues quickly and effectively.

Step 1: Understand the Basics of Debugging

Debugging is the process of identifying and fixing errors in your code. It involves identifying the problem, isolating the source of the issue, and then correcting the faulty code.

function buggy_function() { $undefined_variable += 1; // Causes a PHP notice }

In the example above, you’ll receive a PHP notice because the $undefined_variable was not defined before it was used.

Step 2: Enable WordPress Debug Mode

To help facilitate the debugging process, WordPress comes with specific debug systems designed to simplify the process. The WP_DEBUG is a PHP constant (a permanent global variable) that can be used to trigger the “debug” mode throughout WordPress.

To enable this, you’ll need to access the wp-config.php file, which is located in the root of your WordPress file directory.

// Open your wp-config.php file and look for define('WP_DEBUG', false);
// Change it to: define('WP_DEBUG', true);

When WP_DEBUG is set to true, WordPress will start displaying PHP errors, notices, and warnings, which can help identify any issues.


Two other useful debugging tools in WordPress are the WP_DEBUG_LOG and WP_DEBUG_DISPLAY. WP_DEBUG_LOG is a companion to WP_DEBUG that causes all errors to also be saved to a debug.log log file inside the /wp-content/ directory.

define('WP_DEBUG_LOG', true);

This is useful if you want to review notices later. The WP_DEBUG_DISPLAY controls whether debug messages are shown inside the HTML of pages or not. The default is ‘true’, which shows errors and warnings as they are generated.

define('WP_DEBUG_DISPLAY', false);

Setting this to false will hide all errors. This is particularly useful for live sites where you don’t want errors to display to visitors.


You can also use the SCRIPT_DEBUG PHP constant to force WordPress to use the “dev” versions of core CSS and JavaScript files instead of the minified versions that are normally loaded. This is useful when you are testing modifications to any built-in .js or .css files.

define('SCRIPT_DEBUG', true);

Step 5: Deploy Other Debugging Tools

Beyond the built-in WordPress debugging tools, there are several other PHP and web-specific debugging tools that can be extremely helpful.

  1. PHP Error Log: This is a server-specific feature and may not be available on all hosts. However, if it is, it can be incredibly helpful to see PHP errors related to your site that may not be specifically related to WordPress.
  2. Web Console: Browsers have debug consoles. For example, in Google Chrome, you can right-click, select “Inspect,” then choose “Console” to see JavaScript errors and other front-end issues.
  3. WordPress Plugins: Plugins like Query Monitor can help you debug database queries, PHP errors, hooks and actions, block editor blocks, enqueued scripts and stylesheets, HTTP API calls, and more.

Debugging your WordPress site can seem like a daunting task, especially if you’re new to programming or web development. But with the right tools and a systematic approach, you can identify and solve most issues that arise. Remember to keep WP_DEBUG and other debugging tools off on a live site to prevent displaying errors to your visitors. Happy debugging!