How to Create a Custom Maintenance Mode Page in WordPress

Jan M Jan 26, 2025 Maintenance Mode
How do I show a special page while my website is being worked on?
What methods can I use to implement a custom maintenance mode page in WordPress, ensuring that it’s user-friendly and search engine-friendly?
Andy answered Jan 26, 2025

Why Use Maintenance Mode?

A maintenance mode page helps you keep visitors informed while you're updating your site, fixing issues, or making significant changes. It's essential for providing a professional experience during site maintenance.

Method 1: Using WordPress Core Function

The simplest way to enable maintenance mode is using WordPress's built-in functionality. Create a file named maintenance.php in your site's root directory:

Create a basic maintenance page:

<?php
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) {
    $protocol = 'HTTP/1.0';
}
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 600' );
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Site Maintenance</title>
    <style>
        body { font-family: Arial, sans-serif; padding: 50px; text-align: center; }
        h1 { font-size: 36px; margin-bottom: 20px; }
        p { font-size: 18px; }
    </style>
</head>
<body>
    <h1>We'll be back soon!</h1>
    <p>We're currently updating our site. Please check back later.</p>
</body>
</html>

Method 2: Using Custom Code in functions.php

Add this code to enable maintenance mode for non-admin users:

function custom_maintenance_mode() {
    if (!current_user_can('edit_themes') && !is_admin()) {
        wp_die('<h1>Site Under Maintenance</h1><p>We are performing scheduled maintenance. Please check back soon.</p>', 'Maintenance Mode', array('response' => 503));
    }
}
add_action('get_header', 'custom_maintenance_mode');

Method 3: Using .htaccess (Apache Servers)

Add these rules to your .htaccess file:

# BEGIN Maintenance
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123$
RewriteRule ^(.*)$ /maintenance.html [R=307,L]
</IfModule>
# END Maintenance

Best Practices

  1. Always set proper HTTP status codes (503)
  2. Include a Retry-After header
  3. Allow admin access during maintenance
  4. Keep maintenance periods short
  5. Provide clear information about downtime
  6. Include your logo and branding
  7. Add an estimated completion time if possible

Security Considerations

  • Don't expose sensitive information on the maintenance page
  • Ensure admin access remains secure
  • Monitor maintenance mode status
  • Remove maintenance files after completion
  • Keep IP whitelist updated if using one

Recommended Plugins

  1. WP Maintenance Mode

    • Feature-rich, customizable templates
    • Countdown timer option
    • Plugin Page
  2. SeedProd

    • Coming soon and maintenance mode pages
    • Custom designs and templates
    • Plugin Website

Common Pitfalls

  • Forgetting to disable maintenance mode
  • Not testing maintenance page appearance
  • Blocking search engines unnecessarily
  • Using incorrect HTTP status codes
  • Not providing access to administrators
  • Forgetting to backup before maintenance

Quick Implementation Tips

  1. Test maintenance mode with private browsing
  2. Keep a backup of your IP for whitelist access
  3. Set up monitoring to ensure maintenance mode doesn't stay active accidentally
  4. Consider using a staging site for major updates instead
  5. Include contact information on the maintenance page

This solution provides various methods to implement maintenance mode, allowing you to choose the one that best fits your needs while maintaining SEO-friendly practices and user experience.