• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Bitz

A curated collection of code snippets for WordPress

  • Home
  • About
  • Blog
  • Code Snippets
You are here: Home / WordPress Development Tips / Using WordPress Debug Constants

Using WordPress Debug Constants

WordPress Development Tips · February 6, 2020

Here are some constants you can define in your wp-config.php file to assist with debugging.

Note that debugging should not be enabled on a production site, or if it is, it should be “silent” (i.e. writing to the log, but not displaying on the screen). Also for production use, keep in mind that debugging should be temporary. Constantly writing debug messages to the log will eventually slow your site down as the log grows larger. Leaving this on indefinitely could eventually crash the site when the log grows too large to handle.

Debugging in WordPress

WP_DEBUG

This is the core WP constant that enables debugging. Setting this to true (see the example code at the end) will allow PHP error messages to be printed to the screen and/or the log. Used alone, without any of the additional constants will display errors, warnings, and notices to the screen but not to the error log file.

WP_DEBUG_LOG

This constant is a companion to WP_DEBUG and it causes all errors to be written to a log file. By default, this log file will by located in /wp-content/debug.log.

WP_DEBUG_DISPLAY

This constant is a companion to WP_DEBUG and it causes all errors to be displayed on screen in the browser.

SCRIPT_DEBUG

This little known constant is an important one for testing and debugging WordPress sites. When set to TRUE, it causes WP to load non-minified versions of CSS and JS files. If plugins or themes are properly constructed to WP standards, it will load non-minified versions of those assets as well.

SAVEQUERIES

This constant saves database queries to an array and that array can be displayed to help analyze them. It’s important to note that this constant has a definite performance impact and should only be used when actually debugging.

Filed Under: WordPress Development Tips

Chad Butler

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Join for free!

Get free code snippets, WordPress best practices, and practical Content Marketing advice from seasoned WordPress expert Chad Butler (butlerblog):

Recent Posts

  • Block an IP address from accessing your site
  • Using WordPress Debug Constants
  • Save WordPress debug log by date
  • Utility function for the WordPress error log
  • How to Create a Site Specific Plugin

Copyright © 2021 · Maker Pro on Genesis Framework · WordPress · Log in