Debugging WordPress

If you accidentally introduce a syntax or fatal error in one of your template files, you’ll probably see the dreaded white screen of death when you visit your home page. In some cases, even the admin screens will go blank. Lets see how you can fix this…

If you accidentally introduce a syntax or fatal error in one of your template files, you’ll probably see the dreaded white screen of death when you visit your home page. In some cases, even the admin screens will go blank. The best way to figure out what happened is to check your PHP error log. Look for the last error shown and try to correct it. However, if you can’t find your error log (or you don’t have one), you can turn on debugging by adding define('WP_DEBUG', true); to your wp-config.php file.

The problem with this method, though, is that everyone who visits the site will see your errors. Fortunately there is an alternative, which lets you enter debug mode by adding a query string to any URL.


if ( isset($_GET['debug']) && $_GET['debug'] == 'debug')
define('WP_DEBUG', true);

Then you can just add ?debug=debug to your URL (e.g. http://mysite.com/category/news/?debug=debug) to see the errors.

The white screen of death usually comes up when you update a theme or plugin. If your theme has gone horribly wrong and you just want to switch back to another one, but you can’t access the admin screens to change it, don’t panic. Simply delete or rename your active theme’s directory. When WordPress can’t find it, it will revert to the default theme. You can also deactivate an error-causing plugin by deleting or renaming its directory. WordPress will automatically deactivate it.

  1. Thanks for sharing this tip! 🙂

    Like

    Reply

    1. I am glad you found it helpful.

      Like

      Reply

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: