Debugging WordPress

When working on a plugin or theme, have you ever went to your browser to test some changes, only to be greeted by the dreaded blank white screen? Sometimes the bug in your code is immediately apparent, but what about the times when it’s not? Wouldn’t it be useful if you could see the PHP errors, instead of a blank screen?

The good news is: you can. Just add this simple constant to your wp-config.php file:

define('WP_DEBUG_DISPLAY', true);

Be aware that it’s a bad idea to do this on a production server, as some errors may betray dangerous information, such as system paths or database credentials.

What if you need to see errors on a production server, or you need a record of the errors? You can have them output to a log file (wp-content/debug.log).

define('WP_DEBUG_LOG', true);

You can use either statement alone, or both at the same time.