How to Put WordPress in Maintenance Mode
Redesigning a page, importing products, or building a new site on the live domain: sometimes visitors shouldn’t see what you’re doing. Maintenance mode shows them a simple “back soon” page while you, logged in, keep working.
The right way to go offline: status 503
Search engines need to know the downtime is temporary. A maintenance page should return HTTP status 503 Service Unavailable with a Retry-After header. A normal 200 page saying “coming soon” can be indexed in place of your real content.
Option 1: WordPress’s built-in maintenance file
During core and plugin updates, WordPress creates a .maintenance file in the site root and shows “Briefly unavailable for scheduled maintenance”. You can create one yourself:
<?php $upgrading = time(); ?>
Save it as .maintenance in the WordPress root. It’s crude: it blocks everyone, including you, and WordPress ignores it after ten minutes.
Option 2: a small snippet
This shows a maintenance page with a proper 503 to everyone who can’t manage the site, while admins see the real site:
add_action( 'template_redirect', function () {
// Admins and designers see the real site.
if ( current_user_can( 'edit_theme_options' ) ) {
return;
}
header( 'Retry-After: 3600' );
wp_die(
'<h1>Back soon</h1><p>We are updating the site. Please check back in an hour.</p>',
'Maintenance',
[ 'response' => 503 ]
);
} );
Remove it when you’re done. If you use page caching, purge it after turning maintenance off, and make sure the cache didn’t store the maintenance page.
Option 3: only some pages
Often you don’t need the whole site offline, just the page you’re rebuilding. Wrap the snippet in a condition such as is_page( 'pricing' ), so only that page shows the maintenance message.
With DevKit
DevKit includes Maintenance Mode with the options above built in:
- Hide the entire site, or only the homepage, single posts/pages/custom post types, or archive pages.
- Only visitors without managing capabilities see it; admins keep working normally.
- A neutral default template to start quickly, or a custom template where you write the HTML and CSS (just the content of the
<body>, not a full page).
Doing a bigger migration? Also see search and replace in the WordPress database.
