Open In App

How to Put WordPress in Maintenance Mode?

Last Updated : 10 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

WordPress is a powerful and popular open-source platform for building websites that too without writing long codes. It is easy to use and build websites within minutes.

Sometimes website owners want to make some changes to their website, in this situation, they turn on the maintenance mode of the website. The maintenance mode is visible to the users or website audience while the administrators can access the backend to make the changes.

There are two ways to enable maintenance mode in WordPress:

Using Maintenance Plugin

In this approach, we will be using the Maintenance plugin that is provided by the WordPress. That will help you to set the WordPress into Maintenance mode.

Step-by-Step Process To Put Maintenance Mode On Your Website With Plugins

Step 1: Login to your WordPress account.

Step 2: Open your WordPress website dashboard.

wm1

Step 3: Find "Plugins" button on the side panel on the left side on the webpage

wm2

Step 4: Then click on Add a New Plugin

wm3

Step 5: In the search bar on the top right side write Maintenance

wm4

Step 6: Click on Install Now > Activate

wm31

Step 7: Then click on Plugins > Installed Plugins , check if it is properly installed and activated

wm5

Step 8: Find "Maintenance" button on the side panel on the left side on the webpage

wm6

Step 9: In the plugin dashboard, Click on the toggle button to turn maintenance mode On or Off

wm7

Step 10: Now, you can perform changes on website as per your requirement

wm8

Step 11: Make sure to click on Save Changes

wm9

Example:

wm17

Output:

wm18

Using the custom code

In this approach, we will be using the custom code. That will help you to set the WordPress into Maintenance mode.

Step-by-Step Process To Put Maintenance Mode On Your Website using custom code

Step 1: Login to your wordpress account

Step 2: Open your wordpress website dashboard

wm1

Step 3: Find "Appearance" button on the side panel on the left side on the webpage

wm10

Step 4: Then click on Theme Editor

wm11

Step 5: Click on function.php , it is located on the right panel of the webpage

wm12

Step 6: Copy and paste the code below on the 1st line of the php code.

PHP
<?php
    // code
  function wpmaintenance_mode() {
    if (!current_user_can('edit_themes') && !is_user_logged_in()) {
        wp_die('Under Maintenance. Website under planned maintenance. Please try back later.');
    }
}
add_action('get_header', 'wpmaintenance_mode');
?>
wm13

Step 7: Scroll down and Click on Upload Files

wm14

Next Article
Article Tags :

Similar Reads