How to Put WordPress in Maintenance Mode?
Last Updated :
10 Oct, 2024
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.
Step 3: Find "Plugins" button on the side panel on the left side on the webpage
Step 4: Then click on Add a New Plugin
Step 5: In the search bar on the top right side write Maintenance
Step 6: Click on Install Now > Activate
Step 7: Then click on Plugins > Installed Plugins , check if it is properly installed and activated
Step 8: Find "Maintenance" button on the side panel on the left side on the webpage
Step 9: In the plugin dashboard, Click on the toggle button to turn maintenance mode On or Off
Step 10: Now, you can perform changes on website as per your requirement
Step 11: Make sure to click on Save Changes
Example:
Output:
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
Step 3: Find "Appearance" button on the side panel on the left side on the webpage
Step 4: Then click on Theme Editor
Step 5: Click on function.php , it is located on the right panel of the webpage
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');
?>
Step 7: Scroll down and Click on Upload Files