Cloud Service >> Knowledgebase >> WordPress >> How to Enable Maintenance Mode in WordPress?
submit query

Cut Hosting Costs! Submit Query Today!

How to Enable Maintenance Mode in WordPress?

Turning on maintenance­ mode in WordPress comes in handy whe­n your site needs update­s, big tweaks, or problem-solving, without bothering your site­'s users. In this mode, visitors see­ a personal message te­lling them the site isn't available­ right now. Here is your guide to switch on mainte­nance mode in WordPress.

Method 1: Using a Plugin

One of the easiest ways to enable maintenance mode is by using a WordPress plugin. There are several plugins designed for this purpose.

Step 1: Install a Maintenance Mode Plugin

1. Log in to your WordPress admin dashboard.

2. Go to Plugins > Add New.

3. In the search bar, type "Maintenance Mode" or "WP Maintenance Mode."

4. Install and activate the WP Maintenance Mode plugin or any maintenance plugin of your preference.

Step 2: Configure Maintenance Mode Settings

1. After activating the plugin, go to Settings > WP Maintenance Mode (or the plugin’s specific menu).

2. In the General tab, turn on the Enable Maintenance Mode option.

3. Customize the message or template shown to visitors while your site is in maintenance mode. You can usually add custom text, logos, or even a countdown timer.

4. Click Save Settings to activate maintenance mode.

Step 3: Verify the Maintenance Mode

Check your site­ using a private or hidden web window. Do this to make­ sure visitors see your we­bsite's under-construction note as the­y should.

Method 2: Manually Enable Maintenance Mode

One way to turn on mainte­nance mode manually is by altering your the­me's functions.php file. This strategy works pe­rfectly if you'd rather not add a plugin.

Step 1: Add Code to functions.php

1. Log in to your WordPress dashboard and go to Appearance > Theme File Editor.

2. Select the functions.php file from the right-hand sidebar.

3. Add the following code snippet to the bottom of the functions.php file:

php

Copy code

function wp_maintenance_mode() {

    if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {

        wp_die('

Under Maintenance

We are currently performing scheduled maintenance. Please check back later.

');

    }

}

add_action('get_header', 'wp_maintenance_mode');

  1. Save the changes.

Step 2: Verify Maintenance Mode

To make sure visitors see the "Under Maintenance" message, open your website in an incognito window or log out of your admin account.

Step 3: Remove Maintenance Mode

Once you’re done with your changes, simply remove the code snippet from your functions.php file to disable maintenance mode.

Method 3: Using the .maintenance File (Automatic Maintenance Mode)

WordPress automatically enters maintenance mode during core updates. If the update process is interrupted, your site may get stuck in maintenance mode. To manually disable or re-enable it:

Step 1: Access Your Site via FTP

1. Use an FTP client (like FileZilla) or the file manager in your hosting control panel to access your WordPress installation files.

Step 2: Create or Delete the .maintenance File

1. In the root directory of your WordPress installation (the same folder containing wp-config.php), look for a file named .maintenance.

2. To enable maintenance mode, create this file and add the following code:

php

Copy code

$upgrading = time();

  1. To disable maintenance mode, simply delete the .maintenance file.

Final Words

 

Enabling maintenance mode in WordPress helps ensure that your visitors are informed when your site is temporarily unavailable due to updates or changes. Using plugins or manual methods, you can easily control when your site enters and exits maintenance mode. Always remember to disable maintenance mode after completing your updates.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!