Nexcess Logo

Enabling WP_DEBUG and WP_DEBUG_LOG modes in WordPress

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
February 03, 2023

Have you ever encountered a critical error on your WordPress website? You aren’t alone, and help is available.

If “critical” sounds alarming, there’s a good reason for this. Critical errors are among the most severe issues impacting your WordPress website.

So, how can you tell if you have one?

If you use an older version of WordPress and your website has a critical error, you’ll see a blank screen. If you use a newer version of WordPress and you encounter a critical error, here’s the WordPress error message you’ll see:

If you use a newer version of WordPress and you encounter a critical error, here’s the WordPress error message you’ll see.

Enabling WP_DEBUG and WP_DEBUG_LOG modes in WordPress

Thankfully, you can resolve critical errors using the WP_DEBUG WordPress constant during the WP Debug and WP Troubleshooting phases of your web development lifecycle. However, before you get down to fixing a critical error, you’ll want to know where it came from and how it affects your website.

WordPress critical errors: their causes and effects on your website

WordPress critical errors are most likely caused by a malfunctioning plugin, theme, script, or block of code. Generally, these errors are related to PHP, the primary programming language used on WordPress websites.

If your website has one of these errors, visitors won’t be able to access it. This website downtime could harm your business in many ways. For example, it will hurt your website’s traffic, and users won’t be able to purchase products or services through your website.

To get the WordPress site up and running again, you’ll need to eliminate any critical errors. Here’s how WP_DEBUG can help you get the job done.

Overview of the WP_DEBUG mode and constant in the wp-config.php file

The most effective way to troubleshoot a critical error is to enable WP_DEBUG, a fundamental PHP constant in WordPress that you configure in the wp-config.php file for your site. The health of your website depends on the quality of your WP debug and troubleshooting process.

“Debug” comes from debugging, a common activity in software development that involves identifying and removing “bugs” (also known as errors, defects, unexpected behaviors, user interface flaws, and other issues) in your code, application, or technology stack.

You can cross check the bug information generated with the WordPress error logs. With WP Debug mode turned on, you’ll be able to see the various PHP errors occurring on your site. You can use this mode to trace a bug back to the root of the issue. Any error encountered with a plugin, a theme or the code base would be displayed on the webpages (where you received the critical error message).


To enable WP_DEBUG, you’ll need to modify the wp-config.php file. Simply add this code to the file:

define( ‘WP_DEBUG’, true );

Once you enable the WP_DEBUG constant, you’ll find crucial information on the critical error encountered (for example, error type and the affected domain page).

If you use “false” instead of “true” in the code, you’ll disable WP_DEBUG. When you enable WP_DEBUG, you’ll see something like this:

Deprecated: Function create_function() is deprecated in /chroot/home/user_name/domain_name/html/wp-content/plugins/LayerSlider/layerslider.php on line 69

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Testimonials has a deprecated constructor in /chroot/home/user_name/domain_name/html/wp-content/themes/lawbusiness/framework/class/testimonials-posttype.php on line 13

Deprecated: The called constructor method for WP_Widget in LayerSlider_Widget is deprecated since version 4.3.0! Use __construct() instead. In /chroot/home/user_name/domain_name/html/wp-includes/functions.php on line 5409

Having a look at the above debugging information can help you identify problems on your WordPress website. For example, you can find out which components you need to delete or update.

In WordPress, “deprecated” means that a component (for example, a theme or plugin) is no longer supported or has been replaced by a new version.

Overview of the WP_DEBUG_LOG mode and constant in the wp-config.php file

One issue with WP_DEBUG is that once you’ve enabled it, you’ll display error messages on your live WordPress website. Showing visitors your website’s error messages isn’t ideal.

Instead, you’ll want to use the WP_DEBUG_LOG constant in the wp-config.php file to save your WP_DEBUG information in a separate log file (/wp-content/debug.log) that website visitors won’t see.


To create a WP_DEBUG_LOG, ensure you’ve enabled WP_DEBUG in wp-config.php:

define( ‘WP_DEBUG’, true );

After that, you can add the following code to create a WP_DEBUG_LOG:

define( ‘WP_DEBUG_LOG’, true );

With the WP_DEBUG_LOG WordPress constant set to "true" error messages would be written to a file (/wp-content/debug.log) under the domain's file path. Even if you haven’t encountered any critical errors, you should still consider using WordPress logs to understand activity on your site.

Other useful constants for WordPress error debugging

Once you’ve enabled WP_DEBUG and created a log of your WordPress website’s errors (WP_DEBUG_LOG), you can consider applying other constants to assist with error debugging.

For example, you can change how errors are displayed and revert to applying the full version of CSS and full version of JavaScript files.


Use WP_DEBUG_DISPLAY WordPress constant to select whether or not error messages are displayed in the HTML of your site’s webpages.

Selecting “true” will display errors, while “false” will hide them:

define( ‘WP_DEBUG_DISPLAY’, false );
@ini_set( ‘display_errors’, 0 );


WordPress defaults to loading the minified versions of core .css and .js (CSS and JavaScript) files. Minified files contain only essential code, which speeds up website loading.

However, it’s better to work with the full versions of CSS and JavaScript files if you want to identify and fix bugs. This kind of scenario is where the SCRIPT_DEBUG constant comes to the rescue.

To enable the SCRIPT_DEBUG, constant enter the following code in your wp-config.php file:

define( ‘SCRIPT_DEBUG’, true );

Selecting “false” will disable script debugging.

Disabling WP_DEBUG and WP_DEBUG_LOG modes in WordPress

It is not recommended to keep debugging enabled long term on a production WordPress website. The best practice is to enable debugging and find the issue or issues in terms of their root causes.

Once all error conditions have been resolved, then the best practice is to disable debugging on the site by using the “false” value for all the WordPress constants documented in this article.

Final thoughts: get to grips with error debugging in WordPress

If your website shows a critical WordPress error message, you should put the task of debugging and fixing this kind of error at the top of your priority list. In fact, incorporating an adequate WP Debug and WP Troubleshooting process into your web design project is a best practice.

What to expect from our enterprise WordPress hosting

You don’t have time to worry about your WordPress hosting. Upgrade to Nexcess for fully managed, highly-available resources that keep your enterprise online in heavy traffic.

Would you like more information on WordPress error debugging? Nexcess is here to help. We offer round-the-clock support to all customers who purchase a WordPress hosting plan from us.

Furthermore, the Nexcess Knowledge Base and Nexcess Web Blog contains valuable fixes for various problems you might encounter on your WordPress website. For example, the WordPress fixes: troubleshooting WP-CLI issues help article can supplement the information above.

Another item for your priority list is choosing the best hosting provider for your WordPress or WooCommerce website.

Our fully managed WordPress hosting will put your mind at ease. Have a look at the various plans from Nexcess today to find the right one for you.

Recent articles

Related articles

Christy Joy
Christy Joy

Christy Joy has over five years of professional experience as a Senior Server & System Administrator and has enjoyed working with technology platforms at scale her entire career.

Her hobbies and interests include blogging focused on her ample technology insights gained over an accomplished career, traveling, making new friends, listening to music, artistic works, and social networking. To fly high without any limitations is the dream, Christy reminds us all.

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.