The right way to debug PHP in WordPress

Another public service post.

Something’s broken, you think it’s PHP but you aren’t sure and you don’t want to pop up a bunch of awful errors on your site by setting:

define(‘WP_DEBUG’, true);

in your wp_config.php

The solution is to add three more lines so that the whole thing writes to an error log inside of wp-content:

// Enable WP_DEBUG mode

define('WP_DEBUG', true);

// Enable Debug logging to the /wp-content/debug.log file

define('WP_DEBUG_LOG', true);

// Disable display of errors and warnings

define('WP_DEBUG_DISPLAY', false);


// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)

define('SCRIPT_DEBUG', true);