Maintenance mode helps to redirect all pages in your WordPress site to a single page showing the site is undergoing maintenance. It could be a scheduled maintenance or you might want to take down the site for troubleshooting purposes. After you finished the maintenance or solved the problem, you can remove the maintenance mode and allow visitors to see the actual content. When running a WordPress site, you may need to frequently use the maintenance mode and in this article, we will explain how to do that.

Using Maintenance Mode in WordPress

Whatsoever is the reason, there are many ways to enable maintenance mode in WordPress site.

  • Use one of the free maintenance mode plugins available in WordPress plugin section.
  • Some themes also offer built-in maintenance mode feature that you can activate when needed.
  • Finally, you can use a quick code snippet to put your site in maintenance mode without any plugin and if you do not have this feature in your theme.

1. Maintenance Mode Using Plugin

Go to your administrator dashboard and navigate to “Plugins > Add New” section. Search for “maintenance” and find the Maintenance Mode plugin. This a free plugin which is sufficient to enable maintenance mode in your site.

Install Maintenance Plugin
Install Maintenance Plugin

Install and activate the plugin and the plugin will automatically turn on the maintenance mode. Now, open you site in a separate browser or logout from administrator panel and open your site. Remember, you will be able to see the content when you are logged in as an admin. Therefore make sure to use a different browser or logout and check the maintenance mode is enabled on your site.

Maintenance Mode with Frontend Login
Maintenance Mode with Frontend Login

You can also customize the maintenance mode page by navigating to “Maintenance” menu in admin dashboard. Note that you will be able to login to admin panel using “yoursite.com/wp-admin” URL. This login URL will be accessible even you enable maintenance mode to facilitate admin login. This means you will be able to publish content while your site is on maintenance mode. You can customize the followings on the settings page:

  • Change page title, headline, description and copyright information on the footer.
  • Set logo and add background image.
  • Customize colors, font and enable Google Analytics to track the traffic to your maintenance mode page.
  • Enable or disable login option from the maintenance mode page.
  • Add custom CSS code if needed and exclude any pages that you want to bypass the maintenance mode.
Customize Maintenance Mode
Customize Maintenance Mode

The only annoying part is the advertisements showing in plugin’s settings page. However, this is the case with most of the free plugins.

RELATED:  How to Disable and Limit WordPress Post Revisions?

2. Code Snippet Purpose for Maintenance Mode

If you do not want to use an additional plugin, then there is an easy way to enable maintenance mode using a code snippet. You can use this option especially when you want to enable maintenance mode for a short time. For this you have to edit your theme’s functions.php file and add a piece of code snippet.

  • When you in admin dashboard, go to “Appearance > Theme Editor” section.
  • Select your active theme and then select the functions.php file.
  • Paste the below code at the bottom of the file and click “Update File” button to save your changes.
function maintenace_mode() {
if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
die('Maintenance.');
}
}
add_action('get_header', 'maintenace_mode');

It should look like below in theme editor.

Maintenance Mode Code in Functions PHP File
Maintenance Mode Code in Functions PHP File

This code code will show maintenance mode for all users not logged into your site. So, make sure to test your site by logging out of admin dashboard or using a different browser. You should see a quick maintenance message like below simply showing “Maintenance”.

Site in Maintenance Mode
Site in Maintenance Mode

3. Using Theme Options

Lightweight themes like GeneratePress, Astra, OceanWP and Kadence do not offer maintenance mode option. However, there are many commercial themes allow you to force logout all users on your site and put the site under maintenance. Before using a plugin or the code snippet make sure your theme does not offer the same feature.

RELATED:  Top 5 Author Bio Box Plugins for WordPress

Disable Maintenance Mode

If you have enabled maintenance mode using the code snippet, simply go to “Appearance > Theme Editor” and delete the above code from your theme’s functions.php file. Alternatively, use FTP or File Manager to edit functions.php file. When you have installed Maintenance plugin, deactivate and delete it from your site. For theme options, you may need to disable the feature and save the settings to bring your site back online.

In all the cases, make sure to purge cache of your caching plugin, server side cache and CDN caching to make sure users can quickly view your content.

Similar Posts

Leave a Reply

Your email address will not be published.