In This Tutorial:
Although it is more secure to disable errors from displaying on your website, at times, it may be necessary to enable debugging. Enabling debugging errors can help you to diagnose and resolve issues with your website. In this guide, you can learn how to check, enable, and disable debugging using WP-CLI.
Check Debugging Status
Using the wp config list command, you can determine if the WP_DEBUG constant is set to true (enabled) or false (disabled).
- SSH into your server as the user that will be running WP-CLI.
- Use the cd command to switch to the document root directory of your website.Example: cd public_htmlNOTE: Be sure to replace public_html with the actual path to the document root directory of your website.
- Run the following command:wp config list WP_DEBUG
The following output will be displayed once the command finishes running:
[email protected] [~/public_html]# wp config list WP_DEBUG +----------+-------+----------+ | name | value | type | +----------+-------+----------+ | WP_DEBUG | false | constant | +----------+-------+----------+
Enable Debugging
The WP-CLI command wp config allows you to generate a wp-config.php file, list variables, constants, and file includes defined in the wp-config.php file, set the value of a specific constant or variable defined in wp-config.php file and more. In this section you can learn how to set WP_DEBUG to true to enable debugging mode for WordPress.
- SSH into your server as the user that will be running WP-CLI.
- Use the cd command to switch to the document root directory of your website.Example: cd public_htmlNOTE: Be sure to replace public_html with the actual path to the document root directory of your website.
- wp config set WP_DEBUG true
The following output will be displayed once the command finishes running:
[email protected] [~/public_html/wordpress]# wp config set WP_DEBUG true Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the value 'true'.
IMPORTANT: Be sure to disable debugging when you are done working with your website. This helps to secure your website by hiding errors that may contain private information. The process to disable debugging is the same as outlined in the steps above, simply use false rather than true.
Congratulations! Now you know how to use WP-CLI to check, enable and disable debugging for WordPress.
Learn more about WP-CLI, the command-line interface for WordPress, and streamline your WordPress maintenance workflow!