There are also a few files that live outside the theme directory but still affect how your site looks at times. For example, you can create a file called db-error.php in your wp-content directory and use it to style your database connection error message, as shown in Listing 7-26.
Listing 7-26. Basic db-error.php file
<title>Database Error | MySite.com</title>
<p>The database is not responding, and this site is unavailable. We're sorry! Please try again later.</p>
You can dress this up to match the rest of your site by copying the contents of your theme's header.php, sidebar.php, and footer.php files into the appropriate locations, but remember to remove any WordPress-specific functions, since they won't work if the database is unavailable. You can also link directly to the stylesheet in your theme directory; just remember to change it if you switch themes.
You can also customize your maintenance mode file, maintenance.php (Listing 7-27). 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).
Listing 7-27. Maintenance mode file
$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' ); ?>
<title>Down for Maintenance | MySite.com</title>
<h1>Down for Maintenance</h1>
<p>This site is temporarily unavailable due to scheduled maintenance. Please try again later.</p>
Was this article helpful?