Skip to content

Turn on Debugging in WordPress: WP_DEBUG

One could (and perhaps I should) write a whole course on “how to debug in WordPress.” This (unfortunately) isn’t that post, but rather a quick summary of the best first step in debugging WordPress. It is almost the one step you MUST take if you’d going to debug just about anything in WordPress: make sure WordPress is showing the errors by settings WP_DEBUG to true. This isn’t super complicated, but just an invaluable thing to know.

From there, I generally recommend the following steps to solve the problem (this assumes you’re functional at PHP):

  1. Find the error message that relates to the problem you’re trying to debug.
  2. Find the line of code mentioned in the PHP error. If it’s in your code, you’re set. If it’s in WordPress itself, cry! (Or, just be ready for a more complex procedure that I can’t get into here)

But without further ado, here’s a video walking through how to turn on WP_DEBUG in WordPress:

How to Turn on Debugging in WordPress: Using WP_DEBUG to Solve WordPress Issues

  1. Connect to your WordPress site’s file system. You’ll (most likely) do this via (S)FTP, or if it’s a local install it would just mean using your local computer’s file browser.
  2. Open the wp-config.php file in the root of WordPress file system. This is where WordPress stores site setup details — database connection password, etc.
  3. This file will probably already contain something that look like define('WP_DEBUG', false);. If so, you just need to change that “false” to a “true.” If it doesn’t already contain that line, you’ll need to add it. In either case, make sure that the file contains one (and only one) line defining the PHP constant WP_DEBUG as true. So you want: define('WP_DEBUG', true); to be the final result.
  4. Now you’ll get a message that describes the specific cause of that issue to you.

Unfortunately the issues that need debugging will vary wildly. Maybe it’s an incompatible plugin, a broken theme file, or something else. I can’t even guess. So this is where you debugging skills will need to take over. Here’s a great article from Fred about how to do that:

A Guide to Debugging in WordPress with your Reptilian Brain

Yay! 🎉 You made it to the end of the article!
David Hayes
Share:

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!