Yesterday, you saw [link id=”6287″]how to customize your database error message[/link]. You can also customize your maintenance mode file, maintenance.php
. This is also located in your wp-content
directory and is shown to your visitors while you’re upgrading WordPress core files or plugins. Note that it’s a hidden file on UNIX-based operating systems, so you might have trouble seeing it in some applications unless you turn on the option to view hidden files (if there is one).
Here’s a simple example:
<?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' ); ?> <html> <head> <title>Down for Maintenance | MySite.com</title> </head> <body> <h1>Down for Maintenance</h1> <p>This site is temporarily unavailable due to scheduled maintenance. Please try again later.</p> </body> </html> <?php die(); ?>
Of course, you can dress this up with links to your theme’s stylesheet and any images you’d like to include; just remember to use the direct paths to the files rather than relying on bloginfo()
paths.
Find all the WordPress Hidden Gems in [link id=”2675″]Beginning WordPress 3[/link].
Andrew Nacin says
“Note that it’s a hidden file on UNIX-based operating systems, so you might have trouble seeing it in some applications unless you turn on the option to view hidden files (if there is one).”
Are you referring to the
.maintenance
file? That’s what triggers the maintenance message.Brandon says
Andrew,
No, the .maintenance file is a temp file that’s generated from the maintenance.php file. If you were to somehow edit that (which I doubt you can), it would be deleted anyway once the updates are complete. Performing another update would simply create a new temp file.
In this case, you would have to update the maintenance.php file only.