You can start maintenance mode in WordPress using a plugin or by editing your theme's files.
Using a Plugin:
-
Install a Maintenance Mode Plugin: There are many free and paid plugins available. Some popular options include:
- Coming Soon & Maintenance Mode: This plugin provides basic maintenance mode features and allows you to customize your maintenance page.
- WP Maintenance Mode: This plugin offers more advanced features, including scheduled maintenance mode and the ability to create different maintenance pages for different user roles.
- Maintenance Mode by SeedProd: This plugin allows you to create custom maintenance pages with landing page features and integrates with popular email marketing services.
-
Activate the Plugin: Once installed, activate the plugin from your WordPress dashboard.
-
Configure the Plugin: Access the plugin settings and customize the maintenance page's content, design, and features.
Editing Theme Files:
-
Create a Maintenance File: Create a new file named
maintenance.php
in your theme's root directory. -
Add Maintenance Mode Code: Paste the following code into the
maintenance.php
file:<?php // Start output buffering ob_start(); // Check if the user is logged in if (!is_user_logged_in()) { // Display the maintenance message echo '<h1>Website Under Maintenance</h1>'; echo '<p>Our website is currently under maintenance. We will be back soon.</p>'; echo '<p>Please check back later.</p>'; } else { // Display the normal site content for logged-in users ob_end_flush(); } ?>
-
Activate the Maintenance Mode: Add the following code to your theme's
functions.php
file:<?php // Redirect all non-logged-in users to the maintenance page add_action('template_redirect', 'redirect_to_maintenance_page'); function redirect_to_maintenance_page() { if (!is_user_logged_in()) { header('Location: /maintenance.php'); exit; } } ?>
Important Considerations:
- Back up your website: Before making any changes, back up your website to ensure you can restore it if necessary.
- Test your maintenance mode: After setting up maintenance mode, test it by visiting your website as a regular user.
- Inform your users: Let your users know about the maintenance window and what to expect. You can do this through social media, email, or a notice on your website.