How To Enable Debugging Mode In WordPress To View Errors

Are you experiencing unknown errors or bugs with your WordPress site? If the answer is yes then it may be worth enabling WordPress debug mode via your sites wp-config file to check for any errors.

The wp-config file controls not only your WordPress configuration settings but is also a powerful debugging tool. This tool can help you find any errors plaguing your site by identifying the offending script or plugin that might be causing the issue and can be invaluable to WordPress developers as a result.

In this guide, we will explore how to enable WordPress debugging, and also how to output the debug to a separate log file if needed.

Enabling WordPress Debug Mode:

Note: This guide provides examples to enable Debug mode via cPanel hosting. If you are not on cPanel hosting the same outcome can be achieved by locating & editing your WordPress wp-config.php file via FTP / an alternative file manager.

Firstly, log into your cPanel account. If you are unsure on how to do this, please view the following help article - 'How to log into cPanel'

Then once logged in - under the 'Files' heading, click on 'File Manager'.

Once the File Manager is open, you will need to locate your WordPress wp-config.php file. By default this is located within the root folder of your domain / site.

Firstly, go to the folder your WordPress site is installed in. In this example we have WordPress installed against our main domain on the hosting, so the file will be located within public_html.

Next, locate the 'wp-config.php' file, right click on this then click on 'Edit'

Alternatively you can click on the file to select it, then click on 'Edit' from the options at the top of the File Manager page.

File Manager will then give you an edit prompt to confirm that you would like to edit the file.

Click on 'Edit' to proceed.

The file will then open in a new web browser tab for you to edit.

Scroll down your wp-config.php file until you see the line: /* That's all, stop editing! Happy publishing. */

Just above this, you will then want to add the following line of code:

define( 'WP_DEBUG', true);

It may be that this line already exists as: define( 'WP_DEBUG', false ); If so, simply change the false to true.

Once you've added in the lines you need, click on the 'Save Changes' button at the top of the page.

This line enables WordPress debugging. Any errors or warnings from PHP will then be shown at the top of the page when viewing the site.

Saving the debug output to a log file:

If you would also like to have the debug output logged, simply add the following line of code in as well:

define( 'WP_DEBUG_LOG', true);

This will then log any debug output within your /wp-content folder of your WordPress site as a file: debug.log

Once you've added in the lines you need, click on the 'Save Changes' button at the top of the page.

If you ever want to disable this, simply go back to the wp-config.php file and change the WP_DEBUG  / WP_DEBUG_LOG lines to 'false'