Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Maintenance mode

Visitors see a simple “Back soon” page (with the proper 503 status for search engines) while you work. Logged-in editors see the site as usual.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Developer tools
  • Tested with WordPress 7.1

Before you switch it on: Write your own message in $message. Switch the snippet off when you’re done.

It arrives switched off, even when you install its whole pack with "Switch on after installing".

PHP
<?php

add_action(
	'template_redirect',
	static function () {
		if ( current_user_can( 'edit_posts' ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
			return;
		}
		$message = 'We’re updating the site and will be back within the hour.';
		header( 'Retry-After: 3600' );
		wp_die(
			'<h1>' . esc_html( get_bloginfo( 'name' ) ) . '</h1><p>' . esc_html( $message ) . '</p>',
			esc_html( get_bloginfo( 'name' ) ),
			array( 'response' => 503 )
		);
	},
	0
);

Good to know

The login page, the admin area and the REST API keep working. Page caches may keep showing the normal page: clear them after switching this on.

In these packs

  • Developer tools: Maintenance mode, template names, page stats, environment labels and a WP-Cron viewer.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.