zaro

How to put WordPress in maintenance mode?

Published in WordPress Maintenance 5 mins read

To put your WordPress site in maintenance mode, you can use a plugin for ease of use and customization, or manually implement it by creating a specific file for a quick and simple solution.

Enabling Maintenance Mode with a Plugin

Using a dedicated plugin is the most recommended method for most WordPress users due to its user-friendly interface, customization options, and professional appearance.

Using the WP Maintenance Mode Plugin

A popular choice is the WP Maintenance Mode plugin, which allows you to easily set up and customize your maintenance page.

  1. Install and activate the WP Maintenance Mode plugin from your WordPress dashboard by navigating to Plugins > Add New and searching for it.
  2. Once activated, go to Settings > WP Maintenance Mode.
  3. On the plugin's settings page, you can activate the maintenance mode and typically find options to customize the appearance. Click on the Design tab to personalize the maintenance mode page that your visitors will see when your site is undergoing maintenance. This includes setting up a countdown, contact information, social media links, and custom branding.

Benefits of using a plugin:

  • Ease of Use: Simple activation and deactivation through a graphical interface.
  • Customization: Offers extensive options to design a branded and informative maintenance page.
  • SEO-Friendly: Many plugins automatically send an HTTP 503 "Service Unavailable" status code to search engines, indicating temporary unavailability without negatively impacting SEO rankings.
  • User Experience: Provides a clearer message to visitors than a generic browser error.

Enabling Maintenance Mode Manually

For developers or situations where you need to quickly put your site into maintenance mode without installing a plugin, WordPress has a built-in mechanism.

Creating the .maintenance File

When WordPress updates themes, plugins, or its core, it automatically creates a .maintenance file in your site's root directory. The presence of this file triggers a simple maintenance message. You can leverage this mechanism:

  1. Access your site's root directory (where wp-config.php and wp-load.php are located) using an FTP/SFTP client (like FileZilla) or your hosting provider's file manager.
  2. Create a new file named .maintenance in this directory.
  3. Add a simple PHP code snippet to the .maintenance file. While WordPress displays a default message, you can customize it by adding code that sets a specific timestamp. For a basic trigger without deep customization, just creating the file is often enough, or you can add:
    <?php
    $upgrading = time();
    ?>

    This minimal content is often sufficient to trigger WordPress's default maintenance page.

  4. WordPress will now display a message like "Briefly unavailable for scheduled maintenance. Check back in a few minutes." to all visitors. Administrators logged into the backend might still be able to access the site.

Benefits of the manual method:

  • No Plugin Overhead: Ideal for quick fixes or when plugin installation is not feasible.
  • Core Functionality: Utilizes WordPress's native maintenance capabilities.

Custom Maintenance Mode via functions.php (Advanced)

For advanced users, you can also implement a custom maintenance mode by adding code to your theme's functions.php file. This method offers more granular control, allowing you to specify who can see the site (e.g., only administrators).

However, this method requires comfort with code editing and can potentially break your site if not done correctly. Always use a child theme for such modifications or consider using a staging environment.

Taking Your Site Out of Maintenance Mode

Once your updates or maintenance tasks are complete, it's crucial to disable maintenance mode so your site becomes fully accessible again.

  • For Plugin Method:
    • Go back to the plugin's settings page (e.g., Settings > WP Maintenance Mode).
    • Change the status from "Activated" or "Enabled" to "Deactivated" or "Disabled" and save your changes.
    • Alternatively, you can deactivate the entire plugin from Plugins > Installed Plugins.
  • For Manual Method (.maintenance file):
    • Access your site's root directory via FTP/SFTP or file manager.
    • Delete the .maintenance file. WordPress will immediately revert to normal operation.
  • For functions.php Method:
    • Access your functions.php file (preferably through a child theme or staging site).
    • Remove the custom maintenance mode code snippet you added.

Best Practices for Maintenance Mode

  • Inform Users: If possible, notify your users in advance about scheduled maintenance.
  • Test Thoroughly: Always test your site on a staging environment before pushing updates live.
  • Professional Page: Use the opportunity to display a professional and informative maintenance page that aligns with your brand.
  • Clear Messaging: Clearly state why your site is down and when it's expected to be back online.
  • SEO Consideration: Ensure your maintenance page sends an HTTP 503 "Service Unavailable" header to search engines, which signals that the downtime is temporary and doesn't affect your site's ranking. Most plugins and WordPress's default .maintenance file handle this automatically.

Comparing Maintenance Mode Methods

Feature/Method Plugin (e.g., WP Maintenance Mode) Manual (.maintenance file) functions.php Snippet
Ease of Use Very Easy (GUI) Moderate (FTP/File Manager) Advanced (Code Editing)
Customization Extensive (built-in options) Limited (via maintenance.php file) Full (PHP/HTML)
For Who Beginners & Most Users Developers, Quick Fixes Developers, Custom Logic
Reversibility Easy (toggle/deactivate) Easy (delete file) Easy (remove code)
HTTP Status Typically 503 503 by default Can be configured