I use the function below to manually trigger temporary 'maintenance mode'.

function maintenance_mode(){
if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ){
wp_die('<img src="/graphics/header/logo/1.png" />
<p><strong>Site temporarily offline for maintenance.</strong> </p>' );
add_action( 'get_header', 'maintenance_mode' );

The page title displays as 'WordPress > error' - which I want to replace with a more appropriate alternative.

1 Answer 1


You can pass a title to the wp_die() function or even any other HTML content like heading tags:

But if you are trying to have more control over what's being outputted, you should use the template_include filter and use your custom template:


add_filter( 'template_include', 'show_maintenance_page', 99 );

function show_maintenance_page( $template ) {
    if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ){
        $new_template = locate_template( array( 'maintenance-template.php' ) );
        if ( !empty( $new_template ) ) {
            return $new_template;
    return $template;


Create a file called maintenance-template.php on the root theme folder for this example:

Template Name: Maintenance mode
<img src="<?php echo get_stylesheet_directory_uri(); ?>/graphics/header/logo/1.png" />
    <strong>Site temporarily offline for maintenance.</strong> 
  • Thanks. Passing a title sorts the immediate issue - though I'm interested in your 'template_include' suggestion but having read the linked article still can't understand how to use it in this instance.
    – glvr
    May 29, 2018 at 4:24
  • Hi @glvr I've updated my answer with an example, please take a look now
    – Pabamato
    May 29, 2018 at 21:16
  • Ah, thanks... I see. (And I'm sorry for my slow reply.)
    – glvr
    Jun 4, 2018 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.