Steps
-
Add the complete PHP code to your child theme’s
functions.phpfile or a PHP snippets plugin. -
Activate the snippet.
-
Test the site in a logged-out browser or as a non-administrator.
Hook Used
– template_redirect — Runs before WordPress chooses and loads the front-end template.
Type: WordPress Website Maintenance
Output: Visitors who are not administrators see a maintenance message with an HTTP 503 response. Administrators with the manage_options capability can still access the site.
Important: Disable the snippet when maintenance is complete.
function custom_maintenance_mode_message() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die(
'<h1>We’ll Be Back Soon!</h1>
<p>Our website is currently undergoing scheduled maintenance.</p>
<p>Please check back shortly. Thank you for your patience!</p>',
'Scheduled Maintenance',
array( 'response' => 503 )
);
}
}
add_action( 'template_redirect', 'custom_maintenance_mode_message' );
Tested on
Reported by the author on October 24, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.4. It may still work.
