When adding custom code such as PHP or JavaScript, you may need to identify errors in your code. Enabling WordPress debug mode will log any errors detected on your site. This is useful for troubleshooting issues or learning more about potential problems.
By default, WordPress debug mode is disabled. To enable it:
Access your site files via FTP or cPanel.

Find the wp-config.php file in the root folder of your site.
The wp-config.php file contains site-specific settings such as your database information and configurations from your hosting provider.
Open the wp-config.php file for editing.
Look for this line near the bottom of the file (above the “That’s all, stop editing!” comment):
Copy and paste the following snippet before the line:
// That's all, stop editing! Happy blogging.// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings on the site
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// Use dev versions of core JS and CSS files (only needed if modifying core files)
define( 'SCRIPT_DEBUG', true );
⚠️ This ensures debugging is enabled without displaying errors to site visitors. All logged data will be saved to
/wp-content/debug.log.
After saving the changes, return to your website.
Replicate the error or issue you were experiencing.
This ensures that the problem gets recorded in the debug log.
Navigate back to your site files.
Open /wp-content/debug.log.
The debug log will contain detailed information such as file paths and error messages, helping you track down the source of the issue.
Once you’ve resolved your issue, it’s a good idea to turn off debugging to prevent log files from growing indefinitely:
define( 'WP_DEBUG', false );
Accessing your website with debug mode disabled will no longer show errors on your site.