Title: WP_Fatal_Error_Handler::display_default_error_template
Published: May 7, 2019
Last modified: April 28, 2025

---

# WP_Fatal_Error_Handler::display_default_error_template( array $error, true|WP_Error $handled )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#wp--skip-link--target)

Displays the default PHP error template.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#description)󠁿

This method is called conditionally if no ‘php-error.php’ drop-in is available.

It calls [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)
with a message indicating that the site is experiencing technical difficulties and
a login link to the admin backend. The [‘wp_php_error_message’](https://developer.wordpress.org/reference/hooks/wp_php_error_message/)
and [‘wp_php_error_args’](https://developer.wordpress.org/reference/hooks/wp_php_error_args/)
filters can be used to modify these parameters.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#parameters)󠁿

 `$error`arrayrequired

Error information retrieved from `error_get_last()`.

`$handled`true|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
required

Whether Recovery Mode handled the fatal error.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#source)󠁿

    ```php
    protected function display_default_error_template( $error, $handled ) {
    	if ( ! function_exists( '__' ) ) {
    		wp_load_translations_early();
    	}

    	if ( ! function_exists( 'wp_die' ) ) {
    		require_once ABSPATH . WPINC . '/functions.php';
    	}

    	if ( ! class_exists( 'WP_Error' ) ) {
    		require_once ABSPATH . WPINC . '/class-wp-error.php';
    	}

    	if ( true === $handled && wp_is_recovery_mode() ) {
    		$message = __( 'There has been a critical error on this website, putting it in recovery mode. Please check the Themes and Plugins screens for more details. If you just installed or updated a theme or plugin, check the relevant page for that first.' );
    	} elseif ( is_protected_endpoint() && wp_recovery_mode()->is_initialized() ) {
    		if ( is_multisite() ) {
    			$message = __( 'There has been a critical error on this website. Please reach out to your site administrator, and inform them of this error for further assistance.' );
    		} else {
    			$message = sprintf(
    				/* translators: %s: Support forums URL. */
    				__( 'There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
    				__( 'https://wordpress.org/support/forums/' )
    			);
    		}
    	} else {
    		$message = __( 'There has been a critical error on this website.' );
    	}

    	$message = sprintf(
    		'<p>%s</p><p><a href="%s">%s</a></p>',
    		$message,
    		/* translators: Documentation about troubleshooting. */
    		__( 'https://wordpress.org/documentation/article/faq-troubleshooting/' ),
    		__( 'Learn more about troubleshooting WordPress.' )
    	);

    	$args = array(
    		'response' => 500,
    		'exit'     => false,
    	);

    	/**
    	 * Filters the message that the default PHP error template displays.
    	 *
    	 * @since 5.2.0
    	 *
    	 * @param string $message HTML error message to display.
    	 * @param array  $error   Error information retrieved from `error_get_last()`.
    	 */
    	$message = apply_filters( 'wp_php_error_message', $message, $error );

    	/**
    	 * Filters the arguments passed to wp_die() for the default PHP error template.
    	 *
    	 * @since 5.2.0
    	 *
    	 * @param array $args Associative array of arguments passed to `wp_die()`. By default these contain a
    	 *                    'response' key, and optionally 'link_url' and 'link_text' keys.
    	 * @param array $error Error information retrieved from `error_get_last()`.
    	 */
    	$args = apply_filters( 'wp_php_error_args', $args, $error );

    	$wp_error = new WP_Error(
    		'internal_server_error',
    		$message,
    		array(
    			'error' => $error,
    		)
    	);

    	wp_die( $wp_error, '', $args );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-fatal-error-handler.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-fatal-error-handler.php#L174)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-fatal-error-handler.php#L174-L246)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_php_error_args’, array $args, array $error )](https://developer.wordpress.org/reference/hooks/wp_php_error_args/)

Filters the arguments passed to [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)
for the default PHP error template.

 [apply_filters( ‘wp_php_error_message’, string $message, array $error )](https://developer.wordpress.org/reference/hooks/wp_php_error_message/)

Filters the message that the default PHP error template displays.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Recovery_Mode::is_initialized()](https://developer.wordpress.org/reference/classes/wp_recovery_mode/is_initialized/)`wp-includes/class-wp-recovery-mode.php` |

Checks whether recovery mode has been initialized.

  | 
| [wp_is_recovery_mode()](https://developer.wordpress.org/reference/functions/wp_is_recovery_mode/)`wp-includes/load.php` |

Determines whether WordPress is in Recovery Mode.

  | 
| [is_protected_endpoint()](https://developer.wordpress.org/reference/functions/is_protected_endpoint/)`wp-includes/load.php` |

Determines whether we are currently on an endpoint that should be protected against WSODs.

  | 
| [wp_recovery_mode()](https://developer.wordpress.org/reference/functions/wp_recovery_mode/)`wp-includes/error-protection.php` |

Access the WordPress Recovery Mode instance.

  | 
| [wp_load_translations_early()](https://developer.wordpress.org/reference/functions/wp_load_translations_early/)`wp-includes/load.php` |

Attempts an early load of translations.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 5 more](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#)

| Used by | Description | 
| [WP_Fatal_Error_Handler::display_error_template()](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_error_template/)`wp-includes/class-wp-fatal-error-handler.php` |

Displays the PHP error template and sends the HTTP status code, typically 500.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | The `$handled` parameter was added. | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_fatal_error_handler%2Fdisplay_default_error_template%2F)
before being able to contribute a note or feedback.