Support

Enabling & Disabelling WordPress Debug Mode

WordPress Debug Mode is a feature that logs errors, warnings, and notices that may arise in your WordPress site. While these messages are hidden by default, enabling Debug Mode allows you to see them, which can be particularly useful when developing or troubleshooting.

In WordPress development, debugging is a crucial part of any process. WordPress debugging helps you identify and resolve issues that could impact your WordPress website’s performance, functionality, or security.

Table of Contents

Introduction

Debug Mode in WordPress is a valuable tool for developers and site admins to troubleshoot errors, optimise performance, and ensure compatibility. It helps make it easier to maintain a stable and error-free WordPress website by helping with the following:

Identifying PHP Errors

Debug Mode in WordPress highlights any PHP errors or warnings, helping developers locate and fix code-related issues.

Spotting Deprecated Functions

WordPress evolves frequently, and sometimes functions are marked as "deprecated" before they are removed in future updates. Debug Mode in WordPress flags deprecated functions, helping you future-proof your code.

Finding Compatibility Issues

Plugins and themes can conflict with each other, especially after updates. Debug Mode in WordPress assists in detecting compatibility issues between WordPress, plugins, and themes.

So if this is something you would like to know how to do then read on! This blog is split into 2 sections:

(a) how to enable WordPress debug mode
(b) how to disable WordPress debug mode (when you’re done troubleshooting)

Image 29

But First, Best Practices for Using Debug Mode

There are a few considerations to think about before you start to change things in the WordPress back end, which are:

  • Make a Backup: Before making any changes, download a backup copy of this file to ensure you can restore it if needed.
  • Avoid Enabling on Live Sites: Whenever possible, enable Debug Mode in WordPress on a staging or development site to prevent exposing errors to visitors.
  • Use Debug Logs for Persistent Issues: If your site is encountering frequent issues, enable WP_DEBUG_LOG to maintain a record of errors.
  • Disable Debug Mode When Finished: Leaving Debug Mode enabled can expose site details to visitors and may affect site performance, so disable it as soon as debugging is complete.

By following these steps, you’ll be better equipped to manage Debug Mode effectively, helping you troubleshoot and resolve issues in WordPress while keeping your site secure and user-friendly. So now, lets get into it!

(a) Enabling Debug Mode: A Step-by-Step Guide

To enable Debug Mode in WordPress, you’ll need to modify the wp-config.php file, which is located in the root directory of your WordPress installation.

Step 1: Locate the wp-config.php File

  1. Connect to your website via an FTP client (such as FileZilla) or use your hosting provider's file manager.
  2. In the root directory of your WordPress site (usually named public_html), locate the wp-config.php file.

Step 2: Open wp-config.php and Enable Debugging

  1. Open the wp-config.php file in a text editor (e.g., Notepad, Sublime Text).
  2. Look for the following line:
   define('WP_DEBUG', false);
  1. Change false to true:
   define('WP_DEBUG', true);

This enables basic debugging and will start displaying error messages directly on your WordPress site.

Step 3: Enable Debug Logging (Optional)

If you want to log errors to a file instead of displaying them on the screen (recommended for live sites), add the following lines below define('WP_DEBUG', true);:

   define('WP_DEBUG_LOG', true);
   define('WP_DEBUG_DISPLAY', false);
  • WP_DEBUG_LOG: This will create a debug log file, debug.log, located in the /wp-content directory. The log records all errors, warnings, and notices, which you can review without affecting the front-end display.
  • WP_DEBUG_DISPLAY: Setting this to false ensures that errors are not displayed on the front end, preserving the user experience. Instead, errors are logged to the debug file.

Step 4: Enable Script Debugging (Optional)

For issues related to JavaScript or CSS, you may want to enable script debugging. This tells WordPress to load the unminified versions of JavaScript and CSS files, which are easier to read when debugging script-related issues. The setting to do this is below, and theres no surprises into what you need to do:

   define('SCRIPT_DEBUG', true);

Image 2


(B) How to Disable Debug Mode In WordPress

Once you've identified and resolved any issues within your application, it’s essential to disable Debug Mode to ensure a polished and secure user experience. Leaving Debug Mode enabled on a live site presents significant risks, as it can unintentionally expose sensitive information, such as file paths, configuration details, or even database connections, all of which could be exploited by malicious actors. Additionally, Debug Mode often requires extra processing power to log errors and generate reports, so turning off WordPress debug mode will ensure that you don't noticeably affect your site’s performance and lead to slower load times. Turning off WordPress debug will helo you avoid negative impacts on user satisfaction but can also negatively affect search engine rankings and overall site engagement. Therefore, once the debugging phase is complete, it’s critical to disable Debug Mode to maintain a secure, efficient, and professional live environment.

OK so if its important, then we need to know how to do it right? Well read on below for our step-by-step guide on how to turn off WordPress debug mode:

Step 1: Reopen wp-config.php

The first step to turn off WordPress debug mode is to connect to your website via FTP or your file manager and reopen the wp-config.php file.

Step 2: Disable Debugging

To turn off debugging, change the following line back to false:

   define('WP_DEBUG', false);

If you added additional debugging lines, you can either delete them or set them to false:

   define('WP_DEBUG_LOG', false);
   define('WP_DEBUG_DISPLAY', false);
   define('SCRIPT_DEBUG', false);

Step 3: Check and Delete the Debug Log (Optional)

If you enabled logging, you may find a debug.log file in the /wp-content directory. Review the file for any unresolved issues, then delete it to prevent storing unnecessary files on your server.

Image 3


Summary of WordPress Debug Mode Settings

Here’s a quick summary of the settings related to WordPress debug mode:

SettingDescriptionRecommended Value for Live Sites
WP_DEBUGEnables or disables debugging modefalse
WP_DEBUG_LOGLogs errors to wp-content/debug.logfalse
WP_DEBUG_DISPLAYDisplays errors on the front endfalse
SCRIPT_DEBUGLoads unminified scripts and stylesfalse

Image 19

WordPress debug mode not working?

If debug mode isn’t functioning, the problem usually lies in one of these areas:

  1. Misconfigured wp-config.php File Errors in how debug constants are defined can prevent debug mode from activating in WordPress.
  2. Caching Interference Caching plugins or server-level caching may suppress error messages.
  3. Server Configuration Certain server settings, like disabled error reporting, can stop debug mode in WordPress from displaying messages.
  4. Output Redirection Themes or plugins may redirect errors to alternative log files or suppress them altogether.
  5. Debug Display Turned Off The WP_DEBUG_DISPLAY constant might be set to false, suppressing on-screen error output.
  6. PHP Configuration Issues PHP settings, such as display_errors being turned off, can affect the visibility of debug output.

How to Fix WordPress Debug Mode

Follow these steps to troubleshoot and resolve debug mode issues:

1. Verify Debug Settings in wp-config.php

Ensure that the debug constants are correctly configured in your wp-config.php file. Here’s an example of proper setup:

// Enable WP_DEBUG
define('WP_DEBUG', true);

// Log errors to a file
define('WP_DEBUG_LOG', true);

// Display errors on-screen
define('WP_DEBUG_DISPLAY', true);

// Hide errors from public view
@ini_set('display_errors', 1);

Ensure these lines are placed above the /* That's all, stop editing! Happy publishing. */ comment.

2. Check for Caching

Disable caching plugins temporarily and clear any server-level cache. This ensures cached pages or settings aren’t suppressing error messages.

3. Review PHP Configuration

Verify PHP settings on your server using a PHP info file:

  1. Create a file called phpinfo.php in your WordPress root directory.
  2. Add the following content:<?php phpinfo(); ?>
  3. Access the file in your browser by visiting yourdomain.com/phpinfo.php.

Ensure that display_errors is set to On. If not, modify your server’s php.ini file or contact your hosting provider for assistance.

4. Test Error Logging

Check the debug.log file in the wp-content directory to ensure error logging works. If the file isn’t created:

  • Confirm the directory is writable.
  • Add a simple error in your theme or plugin code to trigger a log entry.

For example:

trigger_error('Test error', E_USER_WARNING);

5. Ensure Plugins and Themes Don’t Override Settings

Some plugins or themes might disable debug mode or redirect error logs. Temporarily deactivate all plugins and switch to a default theme like Twenty Twenty-Three. Test if debug mode works in this state.

6. Use an Alternative Debugging Tool

If WordPress debug mode still doesn’t work, consider using alternative debugging tools:

  • Query Monitor: A plugin that provides in-depth debugging information.
  • Error Logs: Check your server’s PHP error log for issues.

7. Consult Your Hosting Provider

If all else fails, your hosting provider might have specific server configurations affecting debug mode. Reach out to them for support.

Final Thoughts On WordPress Debug mode

If you’re ready to enhance your WordPress site’s performance, security, and professionalism, our expert team is here to help. Navigating technical settings like Debug Mode, optimising site speed, and securing sensitive information are just a few of the ways our agency can support your business goals and elevate your user experience. Don’t leave your site’s success to chance—speak to our WordPress development specialists today and discover how we can tailor our services to meet your unique needs.


Categories:

General
  |  

Transform Your Online
Vision Into Reality