Websites & Apps

Debug Mode in WordPress

DROPIDEA By Admin
June 1, 2025 2 views
DROPIDEA | دروب ايديا - Debug Mode in WordPress

While your WordPress site is running, you will encounter some problems from time to time. Although you may solve these problems at some point, delaying them may cost you complaints or loss of site visitors. So, how can you solve these problems as quickly as possible and ensure that your site remains in perfect condition?

In fact, WordPress offers you a helpful feature that enables you to explore the causes of these problems, which is the Debug Mode feature. Activating this feature on your site shows you the error message in detail and explains to you the reason for its occurrence. This will make it easier for you to locate the error, and thus find a solution to it faster. In this article, we will explain to you how to activate Debug Mode on your WordPress site, and we will also show you how to use it in the best way on your site.

What is Debug Mode in WordPress? By default, the Debug Mode feature is disabled on WordPress sites. Once you activate this mode, you will be able to directly view and troubleshoot the errors your site is facing. You will also be able to record all notifications about problems that appear in a special file called Debug.log.

After this feature displays all the errors on your site, you will be able to solve them yourself if you have the necessary programming skills. Or you can show it to the developer behind the site to help him find the source of the problem and learn more details about it.

Contents of the article: Activate the Debug Mode feature in WordPress 1.

Locate the wp-config.php file 2. Edit the wp-config.php file 3. Add debug code 4.

View error log later Additional important points about Debug Mode 1. Display error log property WP_DEBUG_DISPLAY 2. SCRIPT_DEBUG property 3.

Change the path of the error log file 4. Make sure to disable the Debug Mode feature when finished 5. Activate debug mode using the Activate Debug Mode plugin in WordPress Follow the following steps to activate debug mode on your WordPress site: 1.

Locate the wp-config.php file The WP-config file contains all the settings and features of your WordPress site, and you must have access to it to be able to activate this mode. You can access this file by logging in to your hosting control panel (cPanel), then choosing File Manager, then going to the root folder of the WordPress installation to find the wp-config.php file directly inside it. You can also access the file through the File Transfer Protocol (FTP) by downloading a program that allows communication with the document via the FTP protocol, such as FileZilla.

After downloading the program and logging into it, you will find the wp-config.php file directly in the (Public_html) folder. 2.

Modify the wp-config.php file after accessing the wp-config.php file one of...

In the previous methods, you must modify the code of this important file that contains the configuration settings for your site. Open the file in edit mode by right-clicking on it and selecting Edit. In order to activate the Debug Mode feature, you must find the following line of code within the file.

('WP_DEBUG',false); 3. Add debug code Once you have selected the previous command, delete it and replace it with the following code: // Enable WP_DEBUG mode define( 'WP_DEBUG', true ); // Enable Debug logging to the /wp-content/debug.log file define( 'WP_DEBUG_LOG', true ); // Disable display of errors and warnings define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 ); The first command in the previous code activates the Debug Mode feature on your site by giving the constant WP_DEBUG the value true. The second command activates the feature of writing all errors, notifications and warnings in the site’s log file debug.log by giving the constant WP_DEBUG_LOG the value true. The last two commands disable the two features of displaying errors on the front page of the site so that they do not appear in front of visitors, in order to protect the security of your site and not display sensitive information that may be exploited by Hackers. Note: Each of the properties (WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY) are public programming constants in the PHP language. They are activated by giving them the value true and deactivated by giving them the logical value false. Note that the logical values ​​are written without upper quotation marks “” so that they are not treated as text strings.

4. View the error log later After you have applied the previous commands and made sure that the error correction mode is activated correctly on your site, you can find the special log file that saves all the error messages and problems found on your site and find out the reasons for their occurrence. As we mentioned previously, it is the file wp-content/debug.log (it may be in another path if you changed the default save path).

Debug.log file in WordPress When you activate Debug Mode and set the value of WP_DEBUG_LOG to true as shown above, all errors and problems that occur on the site will be saved in the debug.log file. This file is located in the wp-content directory by default, but you can also save it to another custom path of your choice on the server. Important additional points about Debug Mode After learning about the debugging mode on a WordPress website and its basic features, it is important to learn about some important additional features and points associated with this mode.

1. The error log display feature WP_DEBUG_DISPLAY The primary purpose of this feature is to enable the feature of displaying problems and error messages directly on HTML pages, meaning that they will appear on the site’s front pages and in front of all site visitors. Therefore, you must be careful if you activate this feature on the Live website.

Because if you do this, this may expose you and your site to the risk of sensitive information leaking and it may be exploited by hackers. So if you want to activate this feature, first make sure that the site is not live, then activate it by writing the following command in the wp-config-php file: (‘WP_DEBUG_DISPLAY’, true ); 2. SCRIPT_DEBUG Property This property is useful if you are testing some changes in your JavaScript js files.

Or css files on the site. When this feature is activated with the Debug Mode feature, WordPress uses the Dev versions of these files instead of the compressed (Minified) versions that are usually downloaded, which makes it easier for you to discover and correct errors in them. By default, this feature is not enabled.

To activate it manually, you can add the following command to the file wp–config–php (‘SCRIPT_DEBUG’, true ); 3. Change the path of the error log file as mentioned in the previous commands when activating the Debug Mode feature. We then directly activated the WP_DEBUG_LOG log feature to save all error messages and problems in the debug.log file. You can use the following code to change the path of the file where error reports are saved to protect it from hackers, (‘WP_DEBUG_LOG’, ‘/path/outside/of/webserver/root/debug.log’); 4.

Make sure to disable the Debug Mode feature when you are finished. Debug Mode is certainly a great benefit, as it helps you identify and fix errors and problems on your site. But you should beware that this feature may be able to show text from your PHP code to site visitors if you do not set it up correctly. So you should always remember to disable it after you finish fixing the bugs, and before the site goes live.

5. Activate debug mode using a plugin. If you do not want to activate the Debug Mode feature manually through code, or you do not have access to the wp-config.php file (through the cpanel or FTP hosting control panel), do not worry, as you can still activate it from within the WordPress control panel itself, using plugins. WordPress provides several plugins to control debugging mode, such as WP Debugging, which performs this task automatically.

To install the WP Debugging plugin on your site, log in to the WordPress control panel, then go to the plugins section at the bottom of the control panel, and choose the Add new command. The plugins installation window will appear. Type in the search box the name of the plugin (WP Debugging). After finding the required plugin, click the install now button as shown in the following image. After the installation is complete, then activate the plugin on your site. You can see more information about installing plugins in WordPress. This plugin works immediately after activation, as upon activation it automatically sets the value true for each of the following programming constants WP_DEBUG: This option is activated by default to activate the error debugging mode on the site. WP_DEBUG_LOG: Logs error messages to the debug.log file.

SCRIPT_DEBUG: To force WordPress to use upgraded versions of Javascript and CSS files instead of minified versions. SAVEQUERIES to log database queries and help you track and correct errors. When you deactivate the extension, all of these variables will automatically be set again to the default value of false to deactivate it.

You can also control more plugin settings by going to the Tools tab in the WordPress control panel, then choosing WP Debugging. The plugin settings page will appear as shown in the following image. Through this window, you can activate some additional features by checking the available checkboxes, which are: Set WP_DEBUG to true: This option is activated by default when installing the plugin to activate error debugging mode. Set WP_DEBUG_DISPLAY to false, default is true: By activating this option, you can prevent the feature of displaying messages to site visitors.

Set WP_DISABLE_FATAL_ERROR_HANDLER to true: You can activate this option to enable the site's fatal error handling feature. After activating the options you want, click the Save changes button to save the changes you made to your site. Note: We advise you to deactivate this add-on as soon as you finish fixing the site’s problems, in order to deactivate the error correction mode, which can be exploited by hackers to access important and sensitive data on your site.

Thus, we learned about Debug Mode, which helps you identify and fix errors on your WordPress site. We explained two ways to activate it on the site, either manually by writing the necessary code in the wp-config.php file, or through the WordPress plugin (WP Debugging). Finally, we remind you once again of the need to be careful when dealing with this situation on live sites, as this may affect the performance of the site first, and expose you to the risk of sensitive information leaking second.

Therefore, it is necessary that you cancel it after you finish correcting your site errors.

DROPIDEA

We hope this article has added real value to you. At DROPIDEA, we always strive to deliver high-quality content that helps you grow and evolve in the digital space. Follow us for more useful articles and guides.

Share Article