WordPress Maintenance Mode Without a Plugin Part 2

A few days ago I wrote a post about WordPress Maintenance Mode Without a Plugin. A common question that I got afterwards was whether or not the maintenance page could be styled. The answer, is yes it can be.

After wp-settings.php determines whether or not to put the blog into maintenance mode it checks to see if there is a file titled maintenance.php located in WP_CONTENT_DIR which is by default wp-content/.

Simply create a file at wp-content/maintenance.php containing the code you want to display the for the maintenance page. Below is a sample of code based off of the default maintenance page.

<?php
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
	$protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Maintenance</title>

</head>
<body>
    <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
</body>
</html>
<?php die(); ?>

Modify as needed, add some css, some images and there you go.

About Matt

IF YOU REALLY want to hear about it, the first thing you'll probably want to know is where I was born, and what my lousy childhood was like, and how my parents were occupied and all before they had me, and all that David Copperfield kind of crap, but I don't feel like going into it, if you want to know the truth.

In any case I am employed as a Senior Linux Systems Engineer at Rackspace in San Antonio, TX.

I spent the majority of my college years as an Astrophysics major specializing in black holes. When I got to my senior year and was studying 40 hours a week to stay on track I decided to bail and pursue an easier career.

I spend the majority of my time now contributing to WordPress, developing WordPress plugins, helping out in the WordPress IRC Channel, playing football (not American!), practicing Krav Maga, and last but not least, spending time with my Wife and Son.

This entry was posted in Code, CoolStuff, HowTo, PHP, Snippet, WordPress. Bookmark the permalink.

7 Responses to WordPress Maintenance Mode Without a Plugin Part 2

  1. Excellent post. I am impressed with your writing style. The way you have explained is really good and easy to understand for me. This post will definitely help the newbies like me. I keep seeing articles like these. Thanks for sharing. Keep blogging.

  2. I ABSOLUTELY LOVE YOU!!! This is amazing. I have been looking for something like this for the longest time. I tried it and it works like a charm. Simply Brilliant AMigo!

  3. Great tip. There’s a Post (http://webanthology.net/do-it-yourself-12-wordpress-solutions-without-using-plugins/2009/12/14/) about without-plugin solutions. I think your solution must be there surely.

  4. john r says:

    Slick. A great help. Thx.

  5. Fannar says:

    Great posts! Thanks for sharing

  6. Kate says:

    Thanks so much, this is awesome! Instructions were easy to follow, even for someone who knows just enough code to be dangerous. ;)

  7. William says:

    really helpful, and simple to follow.

    thanks for the details!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre>