Image

How to Enable Maintenance Mode in WordPress

Learn how to inform users that your WordPress site is in maintenance mode by using this clean, simple code snippet from WPCodeBox.

Meet WPCodeBox: The Best Code Snippets Plugin for WordPress
faces
Join thousands of developers and agencies who are working better and faster using WPCodeBox

Every website goes through downtime during updates or major design changes. Leaving your site visible while the layout is broken looks unprofessional and confuses your visitors.

You need a reliable way to hide your work-in-progress while maintaining your own access to the backend.

In this article, I’ll show you how to enable maintenance mode using a simple code snippet. I’ll also show you how to use a page builder if you prefer a visual, no-code approach for your maintenance page.

Why You Should Use Maintenance Mode

Maintenance mode protects your brand by replacing a broken layout or PHP errors with a clean, branded message. 

critical error on website

It also protects your search rankings by adding a 503 Service Unavailable status code. This tells search engines that your site is only temporarily down for updates, rather than being permanently removed. This saves you from the risk of Google de-indexing your pages, which often happens when a crawler encounters a broken site or a 404 error.

Maintenance mode also provides a layer of security during major updates or migrations. Broken websites can sometimes expose sensitive site structures or temporary vulnerabilities to the public. Maintenance Mode ensures that only authorized administrators see the site while it is in a vulnerable state, which keeps your data and configuration private.

How to Enable Maintenance Mode With a Code Snippet

You can install a dedicated maintenance plugin to lock down your site, but most of these plugins add unnecessary bloat to your dashboard for a temporary task. A lightweight code snippet is much more efficient because it handles the restriction without the performance overhead of a plugin.

This approach gives you a clean and reliable way to redirect guest visitors to a simple notification message while allowing you to view and test your site changes normally.

function wpcb_maintenance_mode() {
    if ( !is_user_logged_in() ) {
        wp_die(
            '<h1>Site Under Maintenance</h1><p>We are currently performing scheduled updates. Please check back soon!</p>',
            'Maintenance Mode',
            array('response' => 503)
        );
    }
}
add_action('get_header', 'wpcb_maintenance_mode');

This snippet uses the wp_die function to stop the page from loading for logged-out visitors. You’ll notice the 503 response in the code, which protects your search rankings by informing crawlers that your site will return soon. It is a clean, effective solution for keeping your work-in-progress hidden.

Step-by-Step: Adding the Snippet with WPCodeBox

Adding this code to your theme’s functions.php file is a common approach, but manual file editing often leads to serious technical issues. Your custom code can disappear every time you update your theme, which forces you to re-add your snippets manually. A single misplaced character can also trigger a critical error that takes your entire website offline.

A snippet plugin eliminates these risks by running your code independently from your theme. WPCodeBox is the best plugin for this use case as it allows you to manage all your PHP, CSS, SCSS, and JavaScript snippets from one organized dashboard.

wpcodebox snippet plugin

The plugin creates a secure execution environment with intelligent error detection that prevents most mistakes from breaking your site. This ensures your maintenance mode settings stay active even when you switch themes or run updates, making your customizations truly portable and maintenance-free.

Now that you know why WPCodeBox is the most reliable way to manage your code, let’s look at the steps to add the maintenance mode snippet to your site:

  1. Purchase and install WPCodeBox on your WordPress site. Once activated, find WPCodeBox 2 in your admin sidebar menu. This will automatically open the new snippet creation interface, where you can add your code. 
  2. Name your snippet something clear, like “Enable Maintenance Mode,” so you can easily identify it in your list later. You can also add a brief description in the notes field: “Hides the site from guests with a 503 status code.”
  3. Paste the PHP code from the previous section into the code editor.
  4. Configure these settings in the snippet panel:
    • Type: PHP Snippet
    • How to run the snippet: Always (On Page Load)
    • Where to insert the snippet: Plugins Loaded (Default)
  5. Click the Save button above the editor. WPCodeBox saves your snippet in a disabled state to protect your site from any accidental copy-paste errors.
  6. Review your code one last time to ensure the copied code is without any errors.
  7. Toggle the snippet to “Enabled” status to activate maintenance mode immediately across your site.
Enable maintenance mode snippet

Your maintenance message is now active for all guest visitors while you continue working on the backend. This setup also ensures that search engine crawlers understand your downtime is only temporary, letting you work on your website updates.

How to Enable Maintenance Mode With Breakdance (No-Code)

What if you want to enable maintenance mode without adding any code to your website? If that’s the case, you can use the built-in maintenance mode feature in Breakdance to create a custom-designed landing page in minutes. This no-code approach is perfect if you want to build a high-quality Maintenance page that matches your brand perfectly.

breakdance website builder

Setting Up Maintenance Mode in Breakdance

To create the maintenance mode page using Breakdance, navigate to Breakdance > Settings in your WordPress dashboard and click on the Maintenance Mode tab. You can enable the feature by choosing between 200 Coming Soon for new projects or 503 Maintenance for existing websites. When you select the 503 option, it ensures your SEO stays protected by telling search engines that your site is only temporarily unavailable.

Breakdance maintenance mode settings

You’ll need to select a specific page to display as your maintenance message. If you haven’t designed one yet, you can quickly create a new page, design it with the Breakdance editor, and then return to these settings to select it. Breakdance allows you to add custom contact forms, social links, or countdown timers to keep your audience engaged while you work.

design maintenance page in breakdance

You also have granular control over who can view your site during the downtime. You can configure the access settings so that only users with the Administrator role can bypass the maintenance screen. 

Once your updates are finished, you can simply return to the settings and set the mode back to Disabled. This immediately makes your site accessible to the public and search engines again.

If you prefer to watch the setup process in action, you can follow along with this YouTube video.

How to Verify Maintenance Mode is Active

You can verify your maintenance mode is active by visiting yoursite.com in a new private or incognito browser window where you are not logged in.

If you see your custom maintenance message or the Breakdance landing page, the restriction is working correctly. You should also verify that your administrative access still works by navigating your site in your main browser window.

maintenance page created using Breakdance for guests

If you see your custom maintenance message or the Breakdance landing page, the restriction is working correctly. You should also verify that your administrative access still works by navigating your site in your main browser window.

More on Enabling Maintenance Mode

How do I turn on maintenance mode in WordPress Elementor?

  1. Log in to your WordPress admin area.
  2. Navigate to Elementor > Tools and click the Maintenance Mode tab.
  3. Select Maintenance as your preferred mode from the dropdown menu.
  4. Choose the specific template you want to display to your visitors.
  5. Click Save Changes to activate the screen.

How do I turn off maintenance mode in WordPress?

You can turn off maintenance mode by reversing the method you used to enable it. If you used a code snippet in WPCodeBox, simply toggle the snippet to “Disabled” or delete the PHP filter from your site. If you used a builder like Breakdance or Elementor, navigate back to the maintenance settings in the plugin dashboard and set the status to Disabled before saving your changes.

How to add a coming soon page in WordPress without a plugin?

You can add a coming soon page without a plugin by using a PHP code snippet to redirect guest visitors to a temporary message. This method uses the wp_die function to display your text and a proper status code while still allowing administrators to access the site. Here’s the code snippet to add:


add_action('get_header', function() {
    if ( !is_user_logged_in() ) {
        wp_die(
            '<h1>Coming Soon</h1><p>Our new website is almost ready. Stay tuned for our official launch!</p>',
            'Coming Soon',
            array('response' => 200)
        );
    }
});

More Snippets to Customize Your WordPress Site

Related Tutorials

Image
WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.