Skip to content

Instantly share code, notes, and snippets.

@atelierbram
Last active January 28, 2024 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atelierbram/2ef58619fdaad8a221db1bc69e961d84 to your computer and use it in GitHub Desktop.
Save atelierbram/2ef58619fdaad8a221db1bc69e961d84 to your computer and use it in GitHub Desktop.
WordPress maintenance - minimal setup

If maintenance.php is in a folder called inc within the WordPress theme folder, then include this code at the top of the header.php file of the theme:

  require_once get_stylesheet_directory() . '/inc/maintenance.php';

Everyone not logged in visiting the website will get the message.

<?php
if (! ( is_user_logged_in() ) ): ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<style>
html,
body {
min-height: 100dvh;
background-color: silver;
}
body {
color: #111;
font: 100%/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Verdana,sans-serif;
text-align: center;
padding-top: 3em;
}
</style>
</head>
<body>
<h1><span>⚠</span> Work in progress!</h1>
<p>This website is undergoing maintenance, sorry for the inconvenience!</p>
</body>
</html>
<?php exit; endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment