Buy Theme

Enabling WP_DEBUG in WordPress

WP_DEBUG is a constant that when enabled will display any PHP errors on the front-end of your site, this is the most useful tool when troubleshooting your site for errors. If disabled and your site has an error you may see a blank screen or content missing on the site but no error message, that makes it nearly impossible to figure out the problem.

Important: This is an advanced procedure so please proceed with caution, if you don’t know what you are doing, please contact your webhost for assistance.

How to enable WP_DEBUG in WordPress

  1. Access your website’s root via FTP
  2. Locate the wp-config.php file
  3. Open this file in your favorite text editor
  4. Search for WP_DEBUG and if you find it set the value to true.

If you didn’t locate WP_DEBUG constant you can add it manually above the line:

/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) )
    define( 'ABSPATH', dirname( __FILE__ ) . '/' );

This will enable the error logging and will display PHP errors on front-end. If you don’t want to show errors to everybody you can do the following:

ini_set('display_errors', 0);
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
define('SCRIPT_DEBUG', true);

This code will create file debug.log in your wp-content folder and will add all errors to log file instead outputting to front-end. More information you can find in codex.

Here is a typical configuration on our development environment:

ini_set('display_errors', 1);
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
define('SCRIPT_DEBUG', true);
define('SAVEQUERIES', true);

Categories