Home » Wordpress » How to Create a Custom Database Error Page in WordPress

Paste the code below into a new file. Name it db-error.php and save it on your wp-content directory. In case of a database error, WordPress will automatically use this file.


<?php // custom WordPress database error page tutorial @ santoshkori.com

	header('HTTP/1.1 503 Service Temporarily Unavailable');
	header('Status: 503 Service Temporarily Unavailable');
	header('Retry-After: 3600'); // 1 hour = 3600 seconds
	mail("mail@santoshkori.com", "Database Error", "There is a problem with teh database!", "From: SantoshKori's Blog");

?>

<!DOCTYPE HTML>
<html style="height:100%;">
<head>
<title>Database Error</title>
<style>
body { padding: 20px; background:#fff; color: #999; font-family: arial; text-align:center  }
</style>
</head>
<body style="height:100%;">
  <h1>Captain, the ship can&rsquo;t take much more of this!</h1>
  <p>SantoshKori's Blog is currently experiencing technical issues &mdash; Please check back soon!</p>
  <P>Mail me at <a href="mailto:mail@santoshkori.com">mail@santoshkori.com</a>
  <img src="http://santoshkori.com/blog/wp-content/uploads/2010/10/freelancer-webdesigner-mumbai-india.jpg" style="position:fixed; bottom:5%; right:2%;">
</body>
</html>

Simple, yes, but more effective than the default error page at facilitating a rapid response. Again, because this is a regular PHP file, we can do just about anything with it — more functionality, elaborate design, etc

Here’s an example of the code you could use for this page (see the final output here):

Incoming search terms:

Array ( [0] => Wordpress, Wordpress SEO, Wordpress Tip and Tricks )

Leave a comment

0 Comments.

Leave a Reply

You must be logged in to post a comment.