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
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):
- Find the error message that relates to the problem you’re trying to debug.
- 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
- 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.
- Open the
wp-config.phpfile in the root of WordPress file system. This is where WordPress stores site setup details — database connection password, etc.
- 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_DEBUGas true. So you want:
define('WP_DEBUG', true);to be the final result.
- 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: