September 2, 2019
September 2, 2019
Turning on WP_DEBUG on your WordPress site can give you a better understanding of what’s happening on it, especially when there is an issue. It will also be beneficial for any theme or plugin developers who want their product to be publicly promoted by WordPress.
Therefore, in this article, we will show you everything you need to know about WP_DEBUG and how you can make use of it for your website’s development.
WP_DEBUG is a PHP constant that triggers debugging mode in WordPress. You can find it inside your wp-config.php file. While this mode is disabled by default, you can do many important tasks with it once it’s enabled.
First, it will give you information about how to reproduce an issue. By saving a log file, it records all activities happening on your site and that can help to troubleshoot a problem.
Secondly, WP_DEBUG will display a list of deprecated functions in WordPress theme or plugin releases. These are functions that are marked as inactive in the future. This notification also often lets you know what alternatives can be used instead.
Another important reason for enabling debugging comes when you want to build a theme or plugin.
WordPress Codex highly recommends that every developer use WP_DEBUG when creating their product so that when there’s a problem or warning, another developer can inspect and fix the code.
If it isn’t compatible with WP_DEBUG, the official WordPress tool library won’t endorse your plugin or theme.
Having explained the general idea of what WP_DEBUG is, now we are going to cover practical use.
WP_DEBUG is located in the wp-config.php file and by default has the value set to “false”. If you want to enable it, you have to change it to “true”. To do so, you will need an FTP client, like FileZilla or a file manager to access the file.
In our example, we will use the Hostinger File Manager.
define( 'WP_DEBUG', false )
If there is no such code in your wp-config.php file, you can add it above the /* That’s all, stop editing! Happy blogging. */ line.
Keep in mind that debugging should not be enabled in a live website because this mode is designed for development purposes only.
By enabling WP_DEBUG_LOG, users are able to save all errors in a debug.log file. This function works hand in hand with WP_DEBUG and can help reproduce problems for troubleshooting.
To enable it, open the wp-config.php file and enter this following line under define( ‘WP_DEBUG’, true );
After you activate the function, the debug.log file will be automatically saved in the /wp-content/ folder of your website. You can directly view the file in your browser.
You should disable WP_DEBUG_DISPLAY so the error messages won’t be displayed on your website.
By default, every time there’s an error, it will be generated and shown inside your HTML code. And unlike WP_DEBUG, the original value is “true” and you have to change it to “false” to hide all errors.
Or if it isn’t available, you need to insert this line in the wp-config.php file just below the define(‘WP_DEBUG’, true); line.
All of these features: WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY can be used all at once to enable debugging, save a log file and hide all the errors.
Understanding how to use WP_DEBUG has many important benefits for WordPress site owners and developers alike. You can use it to enable debugging mode and save or hide all errors for better website development. What’s more, the process is actually pretty easy.
Here’s a summary of all steps to make use of WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY:
If you have any questions, just hit us up in the comment section down below!
July 09 2020
I have followed the above procedure , but its still showing the same debug error, it shows the statement: " There has been a critical error on your website" . How can I solve it?
Replied on July 14 2020
Hey there Khaleeq! :) Having the Debug feature on doesn't just resolve the issue - it shows you what went wrong, and how to resolve it. You need to follow the log report and then resolve the issue that way.
August 11 2020
Hello Tomislav "Having the Debug feature on doesn't just resolve the issue - it shows you what went wrong, and how to resolve it. You need to follow the log report and then resolve the issue that way." Can you explain how? where is that report?