How Enable/Disable Debug Mode In WordPress

WP has a debug that allows you to get information when something goes wrong easily. See now how to enable or disable WordPress debug mode.

By Claudio Pires
Updated on July 25, 2022
How Enable/Disable Debug Mode In WordPress

WordPress has a Debug Mode, allowing you to get information when something goes wrong easily. You must add a constant to the WordPress wp-config.php file to enable or disable the debug mode. But what about an easy way to switch on the debug mode, even without accessing wp-config.php?

Disable the Debug mode in WordPress or enable it using a plugin

The first thing to do is to add the following code to your wp-config.php file. This file is located at the root of your WordPress install.

if ( isset($_GET['debug']) && $_GET['debug'] == 'debug')
  define('WP_DEBUG', true);

Once done, simply add a GET parameter to the URL of the page you’d like to debug, as shown below:

http://www.visualmodo.com/?debug=debug

What is Debug Mode?

Debugging PHP code is part of any project, but WordPress has specific debug systems designed to simplify the process and standardize code across the core, plugins, and themes. This page describes the various debugging tools in WordPress and how to be more product active in your coding and increase your code’s overall quality and interoperability.

How enable/disable debug mode in WordPress
How to enable/to disable debug mode in WordPress

WP_DEBUG

WP_DEBUG is a PHP constant (a permanent global variable) 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.

define( 'WP_DEBUG', true );
define( 'WP_DEBUG', false );

Note: The true and false values in the example are not surrounded by apostrophes (‘) because they are boolean (true/false) values. If you set constants to ‘false,’ they will be interpreted as accurate because the quotes make it a string rather than a boolean.

It is not recommended to use WP_DEBUG or the other debug tools on live sites; they are meant for local testing and staging installs.

Debug WordPress with Sublime Text 2 and XDebug
Debug WordPress with Sublime Text 2 and XDebug

History

The WP_DEBUG option was added in WordPress Version 2.3.1.

Starting with WordPress version 2.3.2, database errors are printed only if WP_DEBUG is set to true. In earlier versions, database errors were always printed. (Database errors are handled by the wpdb class and are not affected by PHP’s error settings.)

Starting with WordPress version 2.5, setting WP_DEBUG to true also raises the error reporting level to E_ALL and activates warnings when deprecated functions or files are used; otherwise, WordPress sets the error reporting level to E_ALL ^ E_NOTICE ^ E_USER_NOTICE.

Claudio Pires

Claudio Pires is the co-founder of Visualmodo, a renowned company in web development and design. With over 15 years of experience, Claudio has honed his skills in content creation, web development support, and senior web designer. A trilingual expert fluent in English, Portuguese, and Spanish, he brings a global perspective to his work. Beyond his professional endeavors, Claudio is an active YouTuber, sharing his insights and expertise with a broader audience. Based in Brazil, Claudio continues to push the boundaries of web design and digital content, making him a pivotal figure in the industry.