How to Enable WordPress Maintenance Mode? Print

  • 0

You can set up a WordPress maintenance page when you update your website. Such updates can include changing the design, implementing security updates, etc. Adding a maintenance page will guide your website visitors that it is currently offline and when it is live again.

We have listed three ways to set maintenance mode for your WordPress website. 

Option #1: Set a custom code to the functions.php file. 

You can add the code (given below) at the end of your function.php file

// Activate WordPress Maintenance Mode
function wp_maintenance_mode() {
if (!current_user_can('edit_themes') || !is_user_logged_in()) {
wp_die('<h1>Under Maintenance</h1><br />Website under planned maintenance. Please check back later.');
add_action('get_header', 'wp_maintenance_mode');

Once you add the code, your website will display the Under Maintenance notification.

How can I find the function.php file?

You need to add the code mentioned above in the functions.php file, which is inside your current theme directory at /website root/wp-content/themes/your theme name/functions.php. 

You can connect the FTP and find the functions.php file or directly add it from the wp-admin dashboard

You can edit your current theme from the Theme Editor option depicted in the image below –

Theme Editor

After adding the code to your functions.php file, you will get the screen below on your WordPress main page


Option #2: Install a plugin - WP Maintenance Mode

If you don't want to go with option #1, you can install the wp maintenance mode plugin

  • Once you activate this plugin, a page with the maintenance mode will occur on your website. 
  • After updating your website, you can deactivate the page to reinstate your website.
  • It will also allow you to set up a Custom Page.

WP Maintenance Mode

After activating the plugin, you will see the screen as shown below on your WordPress main page.

Maintenance mode

Option #3: Using .htaccess page

You can add the code (given below) in your .htaccess file to redirect all the pages to maintenance.html

  • In this option, you will need to set your custom page. 
  • Once you set the page called maintenance.html and add the code below in the .htaccess file, all the visitors will get the same page. 

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ [R=307,L]

Was this answer helpful?

« Back