March 17, 2021

WordPress Maintenance Mode: A Complete Guide

Everything You Need to Know About Maintenance Mode

As you build and grow your website, you may find that you’ll need to temporarily hide your website from visitors from time to time. For example, you might need to make substantial changes to your website that require some downtime, or something may break and you’ll need to bring it down to fix the problem. In other words, you’ll need to put your website into maintenance mode.

WordPress websites are essentially no different than the applications you run on your computer. They’re complex pieces of software that require regular updates and maintenance to function reliably. And like your computer’s programs, you can’t access your WordPress site while it’s being updated as doing so can cause problems. Even seemingly simple updates—like a new version of a plugin or theme—can inadvertently cause serious problems. This is precisely why WordPress has maintenance mode.

If you’ve ever started a WordPress update and then tried to access your website while it was still running, you’ve probably seen WordPress’s built-in maintenance mode:

website maintenance mode

For your website’s safety and stability, WordPress will enable maintenance mode for any and all updates, including the core software, plugins, and themes. But beyond that, you can’t turn maintenance mode on and off from any specific setting—it all happens automatically. So what about when you want to enable maintenance mode yourself?

Why Use WordPress Maintenance Mode

There are a few reasons you may want to use maintenance mode for your own purposes. Using it not only prevents problems on your end, it helps create a better user experience too. If a visitor sees the website they’re visiting shifting before their eyes, they’ll likely get a little confused. You’re much better off encouraging them to visit later.

Making Big Changes

In almost any instance where you’ll be making significant changes to your website, you’ll want to use maintenance mode. You may be completely redesigning your website, for example. Or maybe you’re revamping your product lineup for your e-commerce store and you don’t want anyone purchasing old products while you make the necessary modifications. Either way, maintenance mode is the perfect solution.

Launching Your Website

If you’ve been around the web for long enough, you probably remember the old “coming soon” or “under construction” pages. Fortunately, these are far less common nowadays, but there are legitimate reasons to use this kind of page on your website.

For businesses that are already established elsewhere, whether online or off, having a placeholder page on your domain can show visitors that you’re legitimate and encourage them to visit again later once your website is back up. You can use this in creative ways with your marketing too: Getting people to visit your site and create anticipation for a product launch, for example.

Using Maintenance Mode

Now that you know what maintenance mode is and why you’d want to use it, let’s look at how to enable and customize it to best serve your needs.

Enabling Maintenance Manually

Since WordPress has maintenance mode built in, we can actually enable it with just a little bit of code editing. This requires editing the functions.php file of your theme. Be sure to take a backup of your website before you edit any code.

Your functions.php file can be edited by navigating to Appearance and then Editor in your WordPress dashboard. If you don’t see an Editor option, it may be hidden: Some security plugins hide this section for safety reasons. If this is the case, you’ll either need to disable the plugin or login with an FTP client and download your functions.php file for editing.

Once you’ve opened the editor, you’ll see a list of files on the right-hand side. Click on functions.php and then scroll to the bottom of the file on the left and add the code below. If you’re editing the file manually, you’ll add the code with your favourite editor and then upload it back into WordPress.

The code:

// 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><br />We are performing scheduled maintenance. We will be back online shortly!');
    }
}
add_action('get_header', 'wp_maintenance_mode');

This will enable WordPress’s default maintenance mode for anyone that visits your website, with one exception: Users that are logged in and can edit themes will be able to see the regular version of the website.

Keep in mind, if you log out or access the website from a different browser, you’ll also see the maintenance page. You’ll need to go to your WordPress admin dashboard (by default, www.yourdomain.com/wp-admin/) to be able to see your website again.

Once you’re done making changes, you can delete or comment out the code from your functions.php file to return things to normal. Simple as that!

Customizing Your Maintenance Mode Page

While it’s relatively easy to enable maintenance mode using the code above, it takes a little more work to customize the default page. You’ll need to know HTML and CSS if you want to make something that’s similar in style to your current theme and branding.

That said, if you’re up to the challenge, WordPress is already set up to handle it. All you have to do is create a file named maintenance.php and upload it to your /wp-content/ folder. We’ll leave all the design and development up to you.

Using Maintenance Mode With a Plugin

For the rest of the non-programmers out there, there are plugins that can make enabling and customizing maintenance mode much easier. The one that we like is WP Maintenance Mode.

WP Maintenance Mode has quite a few options for customizing your maintenance page. You can add user roles to determine who can access the WordPress dashboard, add pages of your website to exclude from maintenance mode, and more.

Customizing your maintenance page with WP Maintenance Mode isn’t going to win you any design awards, but there’s plenty available to get the job down well enough. You can add and customize a heading, a body of text, and media—such as an image or video. You can also add background images, either by choosing an included one or uploading your own.

WP Maintenance Mode Plugin

Under the modules tab, you can add a countdown timer to your page to show users when they can expect your website to be available again. For those that want to work on their marketing while their website is down, you can add a subscribe form to collect email addresses, as well as add links to all your social networks. You can also enable Google Analytics.

All in all, if you need a simple way to enable and customize your maintenance mode page without any fuss, WP Maintenance Mode is an excellent way to accomplish it.

Stuck in Maintenance Mode

On rare occasions, WordPress can hiccup and get stuck in maintenance mode. This isn’t an occurrence exclusively to using maintenance mode manually; it can happen when WordPress updates its plugins and themes too.

To fix it, you’ll need to connect to your web host with an FTP client. You can use a free program like FileZilla to do so. Once you’ve logged in, you’ll navigate to your WordPress base directory and look for a file called .maintenance and simply delete it. It’s a hidden file, so you’ll need make sure your FTP client is configured to show hidden files. Simple as that!

Conclusion

For those that are running WordPress websites that aren’t overly complex, maintenance mode may never be necessary. But it’s good to know about in case you do ever find yourself in a situation where you need to bring your website down and don’t want to leave your visitors in the dark.

For businesses with more complex websites, maintenance mode is a necessity. Whether you’re doing significant updates and want to keep your visitors in the loop, or you’re adding a new line of products to your e-commerce site and want to ramp up anticipation, maintenance mode is an excellent tool to have in your toolbox.

And if you’re finding that maintenance mode and updates and programming and all of this stuff is simply too overwhelming—that’s fine too! Consider getting some help from some trusty WordPress experts like us to help with all the details so you can focus on doing what you do best.

Join Our Newsletter

Stay up to date on the latest WordPress tips and news