How to enable WordPress Maintenance mode? Print

  • 0

You can set a wordpress maintenance page when updating your website. Such updates could be changing the design, implementing any security updates, etc. Adding a maintenance page will guide your website visitor that your website is currently offline and live again.

We have mentioned the three different ways to set maintenance mode for your Wordpress website. 

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

You can add the below code at the end of your function.php file. Once you add the below code, your website will display the under maintenance notification. 

// 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');

How can I find the function.php file?

You need to add the above code in the functions.php file. You can find this file inside your current theme directory located 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 mentioned in the below image.

You will get the below screen to your Wordpress main page after adding the code to your functions.php file. 

Option #2: Install a plugin - WP Maintenance Mode

If you don't want to go with option #1, you can install the plugin called wp maintenance mode. Once you activate this plugin, a page with the maintenance mode will occur to your website. After updating your website, you can deactivate the page to reinstate your website. It will also allow you to set a custom page.

After activating the plugin, You will get the below screen to your Wordpress main page.

Option #3: Using .htaccess page

You can add the below code inside 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 set the below code inside the .htaccess file, all the visitors will get the same page. 

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

Was this answer helpful?

« Back
Sign up for a newsletter

chat