Skip to content

Debugging

When working on your WordPress site, it’s essential to have tools that make debugging easier. WP_DEBUG is a helpful feature built into WordPress that does just that.

This feature is available on sites with the WordPress.com Creator or Entrepreneur plan.

Enable WP_DEBUG

To activate debugging mode, take the following steps:

  1. Connect to your WordPress site using your preferred SFTP client.
  2. Once connected, locate the wp-config.php file in the root directory of your WordPress installation.
  3. Open the wp-config.php file in your text editor.
  4. Update the WP_DEBUG line: Replace the line define( 'WP_DEBUG', false ); with:
 define( 'WP_DEBUG', true );
   if ( WP_DEBUG ) {
       @error_reporting( E_ALL );
       @ini_set( 'log_errors', true );
       @ini_set( 'log_errors_max_len', '0' );
       define( 'WP_DEBUG_LOG', true );
       define( 'WP_DEBUG_DISPLAY', false );
       define( 'CONCATENATE_SCRIPTS', false );
       define( 'SAVEQUERIES', true );
   }

5. Save the changes you made to the wp-config.php file.

Retrieve Logs

Now you’ve enabled WP_DEBUG, you can retrieve logs to help diagnose issues:

  1. Reconnect to your WordPress site using SFTP.
  2. Navigate to the wp-content directory and locate the debug.log file.
  3. Download or view the debug.log file. You can download the debug.log file to your computer or view it directly using a text editor.

Disable WP_DEBUG

To prevent performance issues and keep sensitive information secure, it’s important to disable WP_DEBUG in your production environment after you’ve finished debugging.

Once you’ve finished debugging, disable WP_DEBUG with the following steps:

  1. Reconnect to your WordPress site again with SFTP.
  2. Locate the wp-config.php file in the root directory of your WordPress installation.
  3. Open the wp-config.php file in your text editor.
  4. Update WP_DEBUG by replacing define( 'WP_DEBUG', true ); with define( 'WP_DEBUG', false );.
  5. Save the wp-config.php file and upload it to your site.

Last updated: April 09, 2024