Posts

Best Way to Put WordPress Website into Maintenance Mode

Sooner or later you’ll probably run into a case where you need to put up a “maintenance mode” page while working on the site. Whether you’re performing simple plugin updates or making full-scale site modifications, maintenance mode is a handy tool to have in your developer’s toolkit. What’s the best way of doing that? When should you use it? How can you do it? These are some questions, Which we will discuss in this blog to put your website into Maintenance Mode WordPress.

What is WordPress Maintenance Mode?

Maintenance mode is a time period during which a website is usually expanded and gets security fixes. During this mode, the users need to be displayed with a message about the unavailability of the website.

Why WordPress Maintenance Mode needed?

Imagine you see a notice that a plugin, theme, or perhaps your WordPress core files require upgrading. You backup your site, run the update, and then there’s an interruption caused by a conflict between the upgrade and existing plugins and you get an internal error, this time your website is not available to your users.

You should use this type of plugin when you need to perform updates to your site and you don’t want your visitors to see the site in an incomplete or transitional state. This maintenance page will display a message to the users that website is not available yet and will available very soon to you.

Method 1: Using Plugins

There are several of these plugins for WordPress, which will put your website into the maintenance mode automatically. These plugins also work great for coming soon pages, It has some customizations, such as changing colors, fonts, and backgrounds. Here are the two best plugins which are best to use.

1. WP Maintenance Mode

This plugin adds a maintenance page to your blog that lets visitors know your blog is down for maintenance, or add a coming soon page for a new website. A user with admin rights gets full access to the blog including the front-end. You can also use a date with a countdown timer for visitor information or set a value and unit for information.

2. Coming Soon Page & Maintenance Mode by SeedProd

A superb maintenance mode WordPress plugin which puts your website into maintenance mode simply by activating the plugin. Anyone who isn’t logged into your website will see the coming soon page, while logged-in users can access the site as normal and do not see the coming soon page which allows you to work on a website during maintenance mode.

 

Method 2: Using function.php file

Adding this part of the code to the functions.php of your WordPress theme will put your WordPress website into Maintenance mode. To disable this code and allow people to access your website again, just comment out the below code.

function maintenace_mode() {
      if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {wp_die('Maintenance.');}
}
add_action('get_header', 'maintenace_mode');

Method 3: Adding .maintenance file

if you don’t want to go through manually putting the site into update mode, then you can create a maintenance mode page in WordPress and put below code into the .maintenance. file

$upgrading = time();

Method 4: Edit index.php file

Many WordPress Maintenance Mode plugins display the message to the users but the truth is most of them have negative SEO impact because some plugin uses error to put the website into maintenance mode. But you can use this snippet to enable SEO positive maintenance mode. Just place this code on the top of index.php file in your root directory for enabling maintenance mode on your website.

require_once('./wp-config.php');
    if(is_user_logged_in())
    {
        if(is_super_admin()){}
        else
        {
            //tells search engine that the webpage is currently unavailable. But will be up after sometime. 
            header('HTTP/1.1 503 Service Temporarily Unavailable');
            
            //use Retry-After only if you know how long the website will be down for.
            //header('Retry-After: Sat, 8 Oct 2011 18:27:00 GMT'); //How long before you estimate your website will be back.
            echo "maintenance mode";
            die();
        }
    }
    else
    {
        header('HTTP/1.1 503 Service Temporarily Unavailable');
        //header('Retry-After: Sat, 8 Oct 2011 18:27:00 GMT'); 
        
        echo "maintenance mode";
        die();
    }

Conclusion

Putting your website into maintenance mode has a number of uses. It’s not reserved only for performing core and regular updates, but it is a useful tactic when you want to make major changes to your website’s design or functionality. We have covered some of the best solutions which you can use to put your website into maintenance mode. You can also join the conversation if you have any other solution or idea which we can use to make it more attractive and easy.

Reference

WordPress: Create a free website or easily build a blog on WordPress.com. Hundreds of free, customizable, mobile-ready designs and themes.

Wp-Maintenence Mode: Adds a splash page to your site that lets visitors know your site is down for maintenance. It’s perfect for a coming soon page.