Many times we get errors/warnings message in the code while executing certain functions. And at times, it is difficult to trace out each and every bug manually. For this reason we need a debugger to find the part of the code which is at fault. The WordPress comes with the inbuilt debugger system called “WP_DEBUG”.
As a quality check we recommend all rtPanel developers to use WP-DEBUG to ensure that their themes is bug free (or with no obvious bugs).
What is WP debug?
In Codex it is mentioned that “WP_DEBUG is a PHP constant (a permanent global variable) that can be used to trigger the “debug” mode throughout WordPress”. In other words, it is an option to enable or disable the PHP errors/warning in the WordPress site.
How to set it true?
By default the WP_DEBUG value is false i.e. the debug mode in WordPress is disabled. To enable the debugger you need to set WP_DEBUG as true in the “wp-config.php” file.
Note: - true/false are the Boolean value and DO NOT enter these value in the apostrophes (‘).
How to use WP-Debug?
Most of the error in the WordPress occurs due to installed plugins or themes (however there can be other coding issues which we will explain in later posts). The plugins that cause error to be displayed can be found out using WP-Debug. Follow the below step.
Deactivate all plugins and uninstall all the third party plugins from the WordPress back end.
Now activate the plugin one by one.
If the error occurs after activating particular plugin then this plugin has fault.
Same is with other remaining plugins.
In this way WP-Debug can be helpful to find the error in the site.
Why to use WP Debug?
As discussed above, enabling WP_DEBUG will display all PHP errors, notices and warnings. It will have following advantages:
It will uncover all PHP Error/warning/notice.
Once the bug is fixed the resulting code will be bug-resistant and easier to maintain.
It will also cause notices about deprecated functions and arguments within WordPress that are being used on your site.
It will be helpful to find out if any plugin or theme is not compatible.
WP Debug mode is one of the powerful tool in WordPress, to display PHP errors, notices and warnings. So if you are developing the site in WordPress, enabling the WP Debug will help you to counter all the PHP errors, notices and warnings. And fixing all those error will make your site more better!!!
Warning: You should be very careful while editing the wp-config.php file as rearranging the contents of the file may create errors on your blog