How to Enable WordPress Debug Mode

Debugging in WordPress is essential for keeping your website running smoothly and free of errors. Whether you're an expert or a beginner, learning to use WordPress's built-in debug tools is key to better troubleshooting. If you use WeWP for hosting, using WordPress Debug Mode is easy and effective.

In this guide, we'll show you how to activate WordPress Debug Mode in a few simple steps. This will help you see detailed information about errors, warnings, and notices on your website. By learning efficient debugging techniques, you can improve your website's performance and provide a better user experience.

What is WordPress Debug Mode?

WordPress Debug Mode is a feature that helps you find and fix problems on your website. When you turn it on, it shows detailed error messages, warnings, and notices. This makes it easier to understand what's wrong and fix it, so your website runs smoothly. It's useful for developers and anyone who wants to keep their WordPress site in good shape.

When Should You Enable WordPress Debug Mode?

You should enable WordPress Debug Mode in the following situations:

  • During Development: When building or customizing your site, catch and fix errors early.

  • Troubleshooting Issues: When your site is experiencing problems, identify the source of errors, warnings, or notices.

  • Testing New Plugins or Themes: Before making them live, ensure compatibility and functionality without errors.

  • After Updates: Following updates to WordPress, themes, or plugins, to catch any new issues that may arise.

Remember to disable Debug Mode on a live site to prevent displaying sensitive information to visitors.

How to Enable WordPress Debug Mode in native WordPress

Before we get into how to enable WordPress Debug Mode, let's look at the different ways to activate it.

If you're comfortable with the code, you can manually edit the wp-config.php file using SSH or an SFTP client. Another easy method is to install a WordPress plugin called WP Debugging.

Here's a quick explanation of the PHP flags we'll use:

  • WP_DEBUG: Turns on debug mode.

  • WP_DEBUG_LOG: Saves error messages to a debug log file.

  • WP_DEBUG_DISPLAY: Controls whether error messages are shown on the website.

Now, let's move on to the step-by-step guide.

How to Enable WordPress Debug Mode in Composer-based WordPress

Before we get into how to enable WordPress Debug Mode, let's look at the different ways to activate it.

If you're comfortable with code, you can manually edit the .env file using SSH or an SFTP client. Another easy method is to install a WordPress plugin called WP Debugging.

Here's a quick explanation of the environment variable flags we'll use:

  • WP_ENV='production': Turns off debug mode

  • WP_ENV=’staging’: Turns off debug mode

  • WP_ENV=’development’: Turns on debug mode

Now, let's move on to the step-by-step guide.

Prerequisites

  • A basic understanding of SFTP (Secure File Transfer Protocol) and SSH (Secure Shell) is essential for accessing and editing files on Cloudways.

  • It is necessary if you understand the structure and content of the wp-config.php file, as it is where WordPress Debug Mode settings will be modified.

  • Please be aware of the risks associated with debugging, as enabling Debug Mode exposes detailed error information, including sensitive data.

Alternatively, you may also seek help from your web developer if you are uncomfortable handling this to ensure proper execution without compromising site security or functionality.

Important Note

We recommend taking an application backup before editing the wp-config.php file, which requires precision and care. Having a backup is a proactive measure to ensure your site's safety and integrity. You can also restore your application to a previous point if unforeseen issues arise.

If you are using WeWP hosting, here are the steps on how to enable WordPress debug mode.

First of all, please select your WordPress type:

  1. Native

  2. Composer based

Native WordPress

Step: #1 You need to connect the server through SSH/sFTP and then perform the below steps to enable debug mode.

Step: #2

  1. To locate the wp-config.php file, use the following command.

a. cd /sites/your_site_name/files

  1. Next, you can simply modify the file by executing the following command.

a. nano wp-config.php

Step: #3

  1. Find the line that says define('WP_DEBUG', false);.

  2. Replace false with true: define('WP_DEBUG', true);.

  3. Optionally, add the following lines to display all errors:

a. define('WP_DEBUG_DISPLAY', true);

b. define('WP_DEBUG_LOG', true);

  1. Save the changes (in nano, press Ctrl + O, then Enter, and Ctrl + X to exit).

  2. Debug mode is now active. To view errors, use a command like:

a. cat wp-content/debug.log.

  1. After completing the troubleshooting process, disable debug mode by setting WP_DEBUG to false and deleting the extra code snippet. Leaving debug mode enabled could pose security risks to your website.

Composer based WordPress

Step: #1 Need to take ssh access to your server.

Step: #2

  1. To locate the wp-config.php file, use the following command.

a. cd /sites/your_site_name/files

  1. Next, you can simply modify the file by executing the following command.

a. nano .env

Step: #3

  1. Find the line that says WP_ENV='production'

  2. Replace false with true: WP_ENV='development’

  3. Save the changes (in nano, press Ctrl + O, then Enter, and Ctrl + X to exit).

  4. Debug mode is now active. To view errors, use a command like: cat web/app/debug.log.

  5. After completing the troubleshooting process, disable debug mode by setting WP_DEBUG to false and deleting the extra code snippet. Leaving debug mode enabled could pose security risks to your website.

Last updated