Enable WordPress Debug Mode

WordPressPosted on

1 min read

WordPress debug mode enables us to see the errors when we develop. It is a necessary step when building something new to be sure that our code works well.

To turn on the debug mode, we have to set the WP_DEBUG constant in the wp-config.php to true:

// Enable WP_DEBUG mode
define('WP_DEBUG', true);

We can also set up (also in the wp-config.php file) where we want to see the errors and warnings, in a log file or on the site:

// Debug logging into a separate file (/wp-content/debug.log)
define('WP_DEBUG_LOG', true);
// Disable error and warning display on site
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

We can also load the development versions of the core JS and CSS files to simplify debugging:

// Load the development versions of core JS and CSS files
define('SCRIPT_DEBUG', true);

The fully enable a manageable WordPress debug setup use the following code:

// Enable WP_DEBUG mode with logging
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
define('SCRIPT_DEBUG', true);

Note that you can also use it on a live site because the messages are only shown in a log file.

Need a web developer? Maybe we can help, get in touch!

Looking for web dev job?
You can check them on Jooble.

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in WordPress category