Sometimes you might need to put WordPress into maintenance mode – this replaces your site with a basic message saying that the site is temporarily unavailable.

Why Use Maintenance Mode?

You might want to activate maintenance mode in situations such as:

  • To correct a mistake in a template (so put it in maintenance while you restore from your ever handy backup)
  • While doing manual updating (for instance the automatic updating failed or a plugin is not available for automatic updating)

Simple Method to Enable Maintenance Mode

In order to do this, simply put a file in the root of your WordPress install and name it .maintenance. The file MUST be preceded by the “.” similar to a .htaccess file.

Normally this file has code in it to indicate how long the site will be under maintenance, and if the timestamp passes then the file is de-activated and the site is available.

For instance, to make the site be unavailable until a specific time (Feb 17th 22:28 2011 in this example) use:

<?php $upgrading = 1297981662; ?>

However, if you want the site to stay in maintenance mode as long as needed, then the timestamp just needs to be kept changing. The following code will do the job:

<?php $upgrading = time(); ?>

And that’s it – you can put WordPress into maintenance mode without a lot of hassle.

Removing Maintenance Mode

To take your site out of maintenance mode, simply delete the .maintenance file from your WordPress root directory.