Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

UPDATE

Initially I suspected this was related to the Wordpress framework I'm using (Genesis) or to my child theme functionality, but turns out that's not the case as I was able to get this to work in a test environment running on the same framework and child theme.

Possibly this is related to the caching plugin I'm using, W3 Total Cache. If this plugin is not active, then the custom db-error.php file is picked up.

To rephrase my question, has anyone run into this issue with caching plugins being active?

ORIGINAL QUESTION

Has anyone successfully been able to replace the default Wordpress database error page with a custom one?

I tried this (add db-error.php under wp-content), but I can't get it to work for some reason: http://css-tricks.com/snippets/wordpress/custom-database-error-page/

share|improve this question

1 Answer 1

This works fine for me as db-error.php in wp-content:

Delete the mailer block if you don't want it

<?php header('HTTP/1.1 503 Service Temporarily Unavailable'); ?>

<?php 
$to = "me@mysite.com"; 
$subject = "My Database is down"; 
$message = "My Database is down"; 
$headers = "MIME-Version: 1.0\n"; 
$headers .= "Content-type: text/plain; charset=iso-8859-1\n"; 
$headers .= "X-Mailer: php\n"; 
$headers .= "From: \"Admin\" <me@mysite.com>\n"; 
mail($to,$subject,$message,$headers); 
?> 


<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
    <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>503 Service Temporarily Unavailable</title>
        <style type="text/css">
            h1, p {
                font-family: Helvetica, sans-serif;
                font-size: 26px;
                color: #333;
                }
            p {
                font-size: 16px;
                }
        </style>
    </head>
    <body>


   <center>
            <h1>My Site is taking a nap right now....</h1>
        <p>But really, we're currently experiencing technical issues &mdash; Please check back soon....</p>
   </center>
    </body>
</html>
share|improve this answer
    
still getting the default WP one. I wonder if it's related to the way I'm triggering the db connection error page (by entering wrong db info in wp-config)? –  IntricatePixels Apr 17 '13 at 2:15
    
Looks like it's related to the caching plugin I'm using, updated my question. Will post more here as I troubleshoot this some more. –  IntricatePixels Apr 20 '13 at 17:58
    
Then disallow that file to be cached in W3TC. –  songdogtech Apr 20 '13 at 18:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.