Although it is more secure to disable errors from displaying on your website, at times, it may be necessary to enable WordPress debugging.
Enabling debugging errors can help you identify specific issues within your WordPress site. You can then use these errors to diagnose and resolve the problems.
In this guide, you will first learn how to verify if WordPress debugging is enabled. Next, we’ll show you the commands for enabling and disabling debugging using backing up your WordPress site before making any changes.
- Check Debugging Status With WP-CLI
- Enable WordPress Debugging Using WP-CLI
- Enable WordPress Debugging Using File Manager
If you’re having trouble with your WordPress host, then check out InMotion’s WordPress Hosting solutions. We provide secure, optimized servers that are priced to meet your budget needs!
Free WordPress Website Transfers Free SSLs Unlimited Bandwidth
View WordPress Hosting Plans
You must install WP-CLI on your server before you can follow these sections.
Check Debugging Status With WP-CLI
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_html
NOTE: 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
You should see an output similar to this when the command finishes running. If the value is “false” debugging is disabled, if it is “true” it is already enabled.
exampl3@example.com [~/public_html]# wp config list WP_DEBUG
+----------+-------+----------+
| name | value | type |
+----------+-------+----------+
| WP_DEBUG | false | constant |
+----------+-------+----------+
Enable Debugging With WP-CLI
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_html
NOTE: Be sure to replace public_html with the actual path to the document root directory of your website.
- Run the following command to enable WordPress Debugging:
wp config set WP_DEBUG true
An output similar to the following will be displayed once the command finishes running.
exampl3@example.com [~/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'.
- 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. For example:
wp config set WP_DEBUG false
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!
Enable WordPress Debugging Using File Manager
WordPress debugging is something that is enabled within your wp-config.php file. With just a simple edit to this file, you will be able to view any errors produced within WordPress. For more information on the WP Debug global variable, see the WordPress Codex page.
- First, be sure that you are logged into cPanel.
- Now that you are logged into cPanel, look for the icon that says File Manager and click on it.
- Within your public_html directory, you will see a file labeled wp-config.php. Right-click on it, then click the Edit option.
- A pop-up message will list the file you are about to modify. Click the Edit button again.
- At the bottom of your wp-config.php file, add the following lines. The first line will cause WordPress to display any errors caused by various PHP functions that are built into WordPress. The second line will display any errors for built-in JavaScript and CSS.
define( ‘WP_DEBUG’, true );
define( ‘SCRIPT_DEBUG’, true );Note: Your wp-config.php file may already have WP_DEBUG set to false. If this is the case, you can simply replace “false” with “true”. Then add the additional lines for SCRIPT_DEBUG and WP_DEBUG_LOG below, if you want them on.
- If you want the errors to be saved to a debug.log file within the “/wp-content” folder add the following line.
define( 'WP_DEBUG_LOG', true );
- After you have edited the wp-config.php file, be sure to click the Save Changes button on the top-right of the file manager.
- Be sure to disable debugging when you are done working with your website. You can do this by commenting out the lines by putting a /* before and a */ after. For example:
/* define( ‘WP_DEBUG’, true ); define( ‘SCRIPT_DEBUG’, true ); define( 'WP_DEBUG_LOG', true ); */
Now that you have enabled debugging within WordPress, you should be able to see any errors that are produced within your WordPress site. Visit our WordPress Education Channel for lots of helpful guides.
Learn more tips and tricks about WordPress backups to protect your website from risks!