Easy WordPress Maintenance mode

Activate the a Maintenance Mode for your WordPress site with this simple snippet. No plugins whatsoever 🙂

Paste the following code into the functions.php file of your theme.

You can customize the text, redirect the users to somewhere else...

function easy_maintenance_mode() {
  if ( !is_user_logged_in() ) {
    die('This is the Maintenance Mode Text');
  }
}

add_action("get_header", "easy_maintenance_mode");

You could also redirect the users to the login page. I find this extremely useful when having the site under construction but you want to client to be able to log in.

function easy_maintenance_mode() {
  if ( !is_user_logged_in() ) {
    header('Location: /wp-admin/');
  }
}

add_action("get_header", "easy_maintenance_mode");

About Rick

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*