How to Debug WordPress Errors

summertime flag cipN2AVwm Q unsplash scaled Debug
This article can be read in about 2 minutes.

To debug errors in WordPress, follow these steps:

  1. Access the wp-config.php File
    Open the wp-config.php file located in the root directory of your WordPress installation.
  2. Enable Debugging
    Find the following line in the file:
   define('WP_DEBUG', false);

Change it to:

   define('WP_DEBUG', true);
  1. Add Additional Debugging Configurations
    Right below the define('WP_DEBUG', true); line, add the following lines:
   define('WP_DEBUG_LOG', true);
   define('WP_DEBUG_DISPLAY', false);
   error_log('Memory usage: ' . memory_get_usage());
  1. Check the Debug Log
    After these steps, WordPress will log errors to the file located at wp-content/debug.log. This file will continuously grow as errors are logged.
  2. Restore Configurations After Debugging
    Once debugging is complete, revert the wp-config.php settings to their original state to stop the debug log from growing indefinitely:
   define('WP_DEBUG', false);

This method helps you diagnose WordPress issues while keeping error details logged in a secure place (debug.log), without displaying them publicly on the website.

Comment

Donate with Cryptocurrency!

Copied title and URL