Enabling debug mode in WordPress is useful for troubleshooting and identifying errors that might occur on your website. By activating debug mode in WordPress shows PHP errors, warnings, and notices on the screen, which provides valuable information for website developers and administrators to diagnose and resolve issues.
Steps to Enable Debug Mode
1. Edit wp-config.php
File
The debug mode which is located in the root directory of your WordPress installation is controlled through the wp-config.php
file. Before making any changes, it’s a good idea to create a backup of the wp-config.php
file.
2. Open wp-config.php
in a Text Editor
Use an FTP client or cPanel File Manager to access the wp-config.php
file. Download the file to your computer, open it in a text editor (such as Notepad or Visual Studio Code), and make the necessary changes.
3. Add Debug Constants
- To enable debug mode, add the following constants to the
wp-config.php
file:
- This line enables debug mode, allowing WordPress to display PHP errors, warnings, and notices on the screen.
- Adding this line will create a log file named debug.log in the
/wp-content/ directory
.
- The log file will record all PHP errors, warnings, and notices instead of displaying them on the screen. This is helpful for keeping the error messages organized and not cluttering the frontend.
- Setting this to false will prevent displaying PHP errors, warnings, and notices on the screen. It’s useful when you want to log the errors in the background but not show them to your website visitors.
4. Save the File
After adding the debug constants, save the wp-config.php
file.
5. Test Debug Mode
Once you’ve enabled debug mode, visit your website and perform the actions that were causing issues. If there are any PHP errors, warnings, or notices, they should now be displayed on the screen (or logged in the debug.log file if you set WP_DEBUG_DISPLAY
to false).
6. Disable Debug Mode (Optional)
After resolving the issues or completing the debugging process, it’s essential to disable debug mode to prevent PHP errors from being displayed publicly. To disable debug mode, either remove the three lines of debug constants from the wp-config.php
file or set the WP_DEBUG
constant to false:
7. Save the file after making the changes.
Remember to be cautious when enabling debug mode, especially on a live website, as it may reveal sensitive information to visitors. It’s best to use debug mode for troubleshooting and resolving the issues and disable it once done.