You have an issue on your website but you’re not sure what it is. This is the time to enable WordPress debugging. Here’s how to do that, and what you need to keep in mind.
But first, a few precautions:
- Only enable debugging when it’s necessary. Don’t keep it on
- Display settings: Log issues quietly, but never expose them to the public (we’ll walk you through hiding this from visitors)
- Stay calm. Troubleshooting and debugging needs a clear, cool head
- Reach out to a professional if you are uncomfortable taking this on yourself
- You will need server access (where your website is hosted)
Now that you are prepared, here’s how to enable debugging:
Step 1: Enable debugging for WordPress
- First, you need to log into your hosting (via cpanel or FTP). In the public_html directory you will see a file called wp-config.php (exactly that, no other words or numbers can appear in the name of this file).
- If you see there is already a line towards the bottom that reads “define( ‘WP_DEBUG’, true );” or “define( ‘WP_DEBUG’, true );” – you already have a partial instruction. Skip to step 5.
- Find the sentence “/* Add any custom values between this line and the “stop editing” line. */“
- Paste the below values here (and above the line “/* That’s all, stop editing! Happy publishing. */”
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Hit save, and head back over to your “public_html” folder and find the .htaccess folder. Click edit, and add the following script above the line “# END WordPress”.
This ensures your debug log is not publicly accessible, which is a security risk.
Require all denied
Hit save again.
Step 2: Check the debug log
Now go back to your public directory and find the subfolder called “wp-content”. Inside it, you will see a new file called debug.log (this file will only appear if there are actual errors on the site. You will not find it if your site has no errors).
Once you find your debug log, download it. This document will contain any errors that are being triggered on your website.
Finished debugging? Time to switch it off
Now that you’ve enabled debugging, you’ll want to view the log which has been created in on your server as a result of the previous step. Simply go back to your wp-config file and remove the lines you added in Step 1.
Note that the debug file will only start populating if there are bugs. So don’t immediately expect the file to be available and populated.
That’s it. Happy debugging.