Maintenance Mode in WordPress

In WordPress 3.0 wp_maintenance() function introduced to die with a maintenance message when conditions are met. You need to create a file .maintenance in the WordPress root directory. In this file, you need to add variable $upgrading and set to the time the file was created. If the file was created less than 10 minutes ago, WordPress enters maintenance mode and displays a message.

You can also display maintenance message more than 10 minutes by adding following code in .maintenance file.

$upgrading = time();

Here, we’ve set current time in $upgrading variable. So WordPress will display maintenance message until you delete .maintenance file.

In WordPress 4.6, enable_maintenance_mode filter introduced to enable/disable maintenance mode. This filter runs before it can be used by plugins. It is designed for non-web runtimes. If this filter returns true, maintenance mode will be active and the request will end. If false, the request will be allowed to continue processing even if maintenance mode should be active.

Default maintenance message is Briefly unavailable for scheduled maintenance. Check back in a minute. The default message can be replaced by using a drop-in (maintenance.php in the wp-content directory).

Categorized as WordPress

By Chandra Patel

I fell in love with WordPress in 2014 while freelancing as a web developer. I have grown since then to become a Core contributor, Translation contributor for Gujarati, and has contributed to WordPress Meta projects. Over the years, I have developed a love for learning, and hope to learn WordPress ever more “deeply”.

%d bloggers like this: