Last Updated on 2021-12-15 by Clay
When we developing the WordPress plugin, if we upload the plugin to the test website directly, sometimes may cause the website display fatal error.
But fatal error is very vague. How do we know which line of the program has the problem? The website does not tell us.
So, we need to enable the DEBUG function of WordPress.
But remember, after plugin testing, we have to disable the DEBUG mode for it. Otherwise, it is easy to be used by those who are interested.
The following records how to enable DEBUG mode, so that developers can clearly understand the error of the code.
WordPress DEBUG mode
You can use FTP application, terminal, or graphical interface to find the wp-config.php file.
In this file, change the value of WP_DEBUG from false
to true
. If possible, also enable the DEBUG Log message.
// define( 'WP_DEBUG', false );
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
After use, if you upload an error in the development plugin, the webpage will print an error message, so that you can troubleshoot the error.
References
- https://wordpress.org/support/article/debugging-in-wordpress/
- https://help.dreamhost.com/hc/en-us/articles/360029327771-Enabling-the-WordPress-Debug-log