Debugging PHP code is a common step in troubleshooting any WordPress site in case it has any issues.

In order to enable Debug Mode, you’d need to have access to your site files whether you are on a local install or your site is hosted somewhere. If you are running a site on your computer, you can simply find the directory where your site files are located and if your site is hosted somewhere, you can get access to your files via FTP or SFTP.

Once you are ready, you will need to add the following code lines to the site’s wp-config.php file:

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 );


This code has to be placed above the /* That’s all, stop editing! Happy blogging. */ line.

It should replace any pre-existing mentions of WP_DEBUG.

If find an existing line like so: define( ‘WP_DEBUG’, false );, delete it!

Once you’ve enabled Debug Mode, recreate the error by trying to access the site’s home page or dashboard again.

A new file should then appear under wp-content/debug.log. In that file, each error will appear on a new line, with the path to the exact file where the error happened. That should help you understand where the error comes from.

Once you’re done debugging, do not forget to replace define(‘WP_DEBUG’, true); by define(‘WP_DEBUG’, false); in the code above.

Feel free to ask questions in comments.

Happy Debugging! 🙂

Posted by Julia Amosova

I love traveling, New York City, coffee, my husband, late mornings, taking pictures, new cool technologies and good books.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s