All about WP Debug

WP_DEBUG is a PHP constant that can be used to trigger the debug mode throughout WordPress. It is assumed to be false by default and is usually set to true in the wp-config.php file on development copies of WordPress.

There are other constants used along with WP_DEBUG constant. Let’s understand the usage of these constants in detail.

  1. WP_DEBUG

    To enable debugging mode, add the following line to the wp-config.php file

    define('WP_DEBUG', true);

  2. WP_DEBUG_LOG

    When WP_DEBUG_LOG and WP_DEBUG are enabled, WordPress saves all error information to the debug.log file in the wp-content directory. By default, this setting is disabled.

    To enable this setting, add the following line to the wp-config.php file:

    define('WP_DEBUG_LOG', true);

  3. WP_DEBUG_DISPLAY

    When WP_DEBUG_DISPLAY and WP_DEBUG are enabled, WordPress displays error and warning messages on web pages. By default, this setting is enabled. When this setting is disabled, debugging messages are hidden from view.

    To disable this setting, add the following line to the wp-config.php file:

    define('WP_DEBUG_DISPLAY', false);

  4. SCRIPT_DEBUG

    When SCRIPT_DEBUG is enabled, WordPress uses development versions of core CSS and JavaScript files instead of the compressed versions that it normally uses. By default, this setting is disabled. You can use this setting to test modifications to built-in .js or .css files.

    To enable this setting, add the following line to the wp-config.php file:

    define('SCRIPT_DEBUG', true);

Putting it All Together

// Turn debugging on

define('WP_DEBUG', true);

// Tell WordPress to log everything to /wp-content/debug.log

define('WP_DEBUG_LOG', true);

// Turn off the display of error messages on your site

define('WP_DEBUG_DISPLAY', false);

// For good measure, you can also add the following code, which will hide errors from being displayed on-screen @ini_set('display_errors', 0);

How to open wp-config.php file

For Updating the wp-config file, Open the terminal and login to your server where the site is hosted (or jump to the local set up.) This file is located inside the root directory of the proeject folder.

  1. Open the terminal
  2. Goto the folder where you wordpress set up is created
  3. Open wp-config.php file with any of favourite editor like nano, vi, vim, etc
  4. Add the line of codes as mentioned above
  5. Save the changes and quit from the editor.

NOTE: Don’t forget that WP_DEBUG is for local development use and should not be used on live sites.

Read more about WP_DEBUG - https://codex.wordpress.org/WP_DEBUG

results matching ""

    No results matching ""