Enabling debug mode in WordPress is a useful way to troubleshoot issues, as it provides more detailed error messages and information about what might be causing problems on your website. To enable debug mode in WordPress, follow these steps:
1. Access Your WordPress Files:
You’ll need access to your WordPress site’s files. This can be done through an FTP client, file manager in your web hosting control panel, or directly on your server. Alternatively you can install this very helpful plugin ‘WP File Manager‘ from WordPress repository to access files straight from your WordPress dashboard and use them to debug errors.
2. Locate wp-config.php File:
This file is located in the root directory of your WordPress installation. Most of the time in folder ‘public_html’. This folder contains all website files that will be shown to a viewer who visits your website. Locate wp-config.php file.
3. Edit wp-config.php file:
- Open file using ‘code editor’ or text editor and Look for the following line of code:
- Replace with these lines:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true);
define( 'WP_DEBUG_DISPLAY', false);
WP_DEBUG_LOG: This will log the debug information to a file in the /wp-content/ directory named debug.log.
WP_DEBUG_DISPLAY: Set to false to prevent debug information from displaying on your site. If you want to see debug information on your site, you can leave it as true.
Make sure to add code above the line ‘ That’s all, stop editing! Happy publishing.’.
4. Save the wp-config.php file
Make sure to save your changes after editing the file.
Related Article: How to Install Captcha Plugin on Website
5. Test your website
Visit your website and perform the actions or access the pages that were causing issues. If there are any PHP errors, they will be displayed on the screen if you set WP_DEBUG_DISPLAY to true. Otherwise, you can check the debug.log file in the /wp-content/ directory for error messages.
If WordPress debug.log file is not created in wp-content folder then try clearing cache, refresh the page, or visit a page on your website. If still there is no log then, Congratulations !, your website is clean of errors and warnings.
How to Disable Debug Mode
Once you’ve resolved the issues, remember to set define(‘WP_DEBUG’, false); in your wp-config.php file to turn off debug mode, especially on a live website. You can also remove the WP_DEBUG_LOG and WP_DEBUG_DISPLAY lines.
Enabling debug mode should be done in a controlled environment and not on a live, production website. Debugging information can reveal sensitive information about your site, so be cautious when using it in a live environment.
Remember that keeping debug mode enabled on a live website can potentially pose security risks, so always disable it when you’re not actively troubleshooting issues.