BLOG
Maintenance Mode: What is it, Why use it?
WordPress Maintenance Mode

Keep the messy maintenance behind the scenes

Use maintenance mode to temporarily block people from seeing your site

In the world of web development, sometimes you need to just take your website down for a little while. Maybe some big updates to your favorite plugins just hit, and you’re worried that they could break your site. What if you’re changing themes, and you want to make sure your website works perfectly right away? Or suppose you’re doing a content overhaul, but want some guidance from others. Enter WordPress maintenance mode! This handy tool makes it so that only those who are signed in (e.g., you, your other admins, etc.) can see your website. Everybody else is presented with a short message that tells them to check back later. Learn how to implement this handy mode in this entry of the Mr. WPress blog!

The quick and easy way: plugins

Fair warning – as a general rule, we recommend using as few plugins as possible on your WordPress website. Too many plugins can conflict with each other, or with the theme. With something that affects your entire website like maintenance mode especially, we tend to suggest staying away from a plugin. It could potentially cause problems that even going into maintenance mode won’t be able to help fix. However, if you’re truly not comfortable using code and/or navigating your theme files, this is an alternative method of implementing maintenance mode.

WP Maintenance Mode by Designmodo is one such solution. You can turn on maintenance mode with a few clicks, and even create a custom page that visitors see. You could even include a countdown timer to let people know the moment you’ll be up and running again! A more barebones solution comes from Lukas Juhas with Maintenance Mode. His plugin is designed to work as simply and efficiently as possible. It even comes with a handy indicator in the WordPress dashboard regarding whether the mode is on or off.

Manual maintenance mode through PHP

However, at Mr. WPress, we recommend simply inserting a little code into the functions.php file of your theme. The code comes courtesy of wpmudev, and looks like this:


// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
    if(!current_user_can('edit_themes') || !is_user_logged_in()){
        wp_die('
<h1 style="color:red">Website under Maintenance</h1>

We are performing scheduled maintenance. We will be back online shortly!');
    }
}
add_action('get_header', 'wp_maintenance_mode');

Just insert that code into your functions.php file, and only logged in users will be able to see your website. Everybody else gets a message telling them that you’ll be back soon, so you can update and rework to your heart’s content! Feel free to change the message as well. Once you’re done, just delete the code from the file, and voila. Maintenance mode made easy – enjoy!

RELATED BLOG POST