Debugging With WP_DEBUG
The most important debugging tool you need to know about is WP_DEBUG.
WP_DEBUG is a boolean constant, which triggers the “debug” mode throughout WordPress. It’s found in the wp-config.php file in your WordPress install.
When set to “true,” you’ll start seeing PHP notices – not so much errors as they are helpful messages for developers – and WordPress-generated debug messages, particularly deprecated function usage, displayed on your site’s pages.
Deprecated functions, which are contained in many WordPress releases, are functions that have been flagged to die at a later date. It’s important to know if you are using a deprecated function in a theme or plugin you’re working on so you can find a replacement to use instead.
To turn on WP_DEBUG, find the following line of code to your wp-config.phpfile:
define( 'WP_DEBUG', false ); |
Then, replace false
with true
and save the file.
To turn the constant off, just replace “true” with “false”. WP_DEBUG is set to false by default.
WP_DEBUG provides a handy way to troubleshoot problems when something goes wrong with your site.
It’s important to keep in mind that WP_DEBUG should not be used on a live site. While it’s a useful feature during development, it can be dangerous on a live site because text in the PHP notices can reveal details about your code, paths and other information to visitors to your site.