There are 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 — not in themes
! — and use it to style your database connection error message:
<html> <head> <title>Database Error | MySite.com</title> </head> <body> <h1>Database Error</h1> <p>The database is not responding, and this site is unavailable. We’re sorry! Please try again later.</p> </body> </html>
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 the link if you switch themes.
If you’re building this error page for a business, offer the user a way to contact you by email or phone rather than just asking them to come back later. Your users will appreciate having some alternative ways to get things done.
Find all the WordPress Hidden Gems in [link id=”2675″]Beginning WordPress 3[/link].
Ozh says
I’d also add a status_header( 500 ); to tell googlebot and such that the page is not at its normal state