Fix the WordPress White Screen of Death in Seconds

This tutorial shows you how to recover from a WordPress white screen of death in the future. If you’re looking at one right now, there’s no shortcut. You need to manually reset your theme, disable your plugins, or both. But if you want to be prepared for next time, and want to recover instantly from a blank screen staring at you when WordPress crashes, then read on.

Table of Contents

Step 1: Insert the Code

Start by adding the following code into your functions.php or custom plugin. If you’re new, follow this tutorial on the proper way to add code to WordPress.

function reset_theme_and_plugins() {
    if (!current_user_can( 'manage_options' ))
    $url = $_SERVER['REQUEST_URI'];
    $getFirstPart = explode('/', $url);
    $getFirstPart = $getFirstPart[1];

    if ($getFirstPart == 'reset-theme') {
        wp_redirect( home_url() );

    if ($getFirstPart == 'deactivate-plugins') {
        $plugins = get_option( 'active_plugins' );
	require_once( ABSPATH . 'wp-admin/includes/plugin.php' );

        wp_redirect( home_url() );

add_action( 'setup_theme', 'reset_theme_and_plugins' );

This creates two special URLs that only administrators can use.


The first one “” automatically sets your theme to the default Twenty Sixteen. It loads well before any error even has a chance to occur. If you want this to default to some other theme instead, change this line:


Replace “twentysixteen” with the folder name of the theme you want to revert to whenever you get a fatal error or a WordPress white screen of death.

The second URL “” immediately deactivates all plugins on your site.

Location of the Above Code

Note that if you paste this code into your theme’s functions.php, you won’t be able to use the second URL after the first. That’s because the theme would have already changed and a new functions.php would be in effect. So if you want to disable plugins while having the above code in functions.php, make sure you run the second URL first!

The reverse is true if you paste the code into a custom plugin. In this case, you need to disable them first using the “reset-theme” URL, and then disable the plugins. If you disable the plugins first, you won’t be able to reset the theme!

In short:

  1. Code in functions.php => Disable plugins first. Disable theme second
  2. Code in custom plugin => Disable theme first. disable plugins second.

Of course, if you’re sure of the source of the problem (plugin, or theme), then you can disable whichever one you want 🙂

Example 1: WordPress White Screen of Death Fix

Let’s say I make a syntax error in my WordPress functions.php and I get either a fatal error or a white screen of death like this:

WordPress white screen of death
WordPress White Screen of Death

Since I know my error lies in my theme’s functions.php (because I just made a change), I type in the first URL to revert back to my “safe” theme – Twenty Sixteen, by typing in;

reseting theme
Resetting the Theme

As soon as this executes, I’m directed back to my home page with the Twenty Sixteen theme installed.

fatal error fixed in seconds
Fatal Error Fixed in Seconds

Everything’s safe. Now I can go back and correct whatever mistake I made.

Example 2: Deactivating all Plugins

Let’s say I get a fatal error or a white screen of death because of an incorrect plugin. In that case, I type in the second URL for deactivating them all:

deactivate plugins
Deactivated Plugins

Now my WordPress site is restored, and all my plugins are deactivated as shown here:

all plugins deactivated
All Plugins Deactivated

Using one, or both of these URLs will fix your WordPress white screen of death in seconds. Sure, it won’t fix the underlying problem. The theme or plugin that caused the error still exists and is messed up. But at least now you have the chance to go in and fix it. Otherwise, you’d be locked out of the admin screen entirely.

Keep in mind that the above code will only work when you try these URLs as an admin user. So it won’t work in a fresh incognito window, or if some other visitor to your site attempts to reset your theme or plugins.

As I mentioned earlier, this tutorial won’t help you if you’re currently stuck on a white screen of death. But it has the potential to save you a lot of time and headaches in the future. Just type in a URL and bam – Your problem is fixed!

About Bhagwad Park

I've been writing about web hosting and WordPress tutorials since 2008. I also create tutorials on Linux server administration, and have a ton of experience with web hosting products. Contact me via e-mail!

Speak Your Mind