A Better Way to Show WordPress Database Errors

If you visit this website often, you may see some downtime issues (due to the Amazon Cloud server issues). and so many times i felt terrible with that message and finally thought of overriding the WordPress Database Error message and give a better look and feel for the user. to achieve this I followed a blog post of Jeff Starr and luckily it worked.

[caption id=”attachment_322” align=”aligncenter” width=”976”]Better way to display WordPress Database Error Better way to display WordPress Database Error[/caption]

Create a file named with db-error.php under wp-content directory and copy and paste the following code. Also style it as you wish.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Terribly sorry :(</title>
</head>
<body>
<div class="container">
<h1>Terribly sorry <span>:(</span></h1>
<p>I am sorry, looks like the Amazon Cloud Servers are't responding or having some technical issues right now.</p>
<p>Sometimes refreshing the browser may work, hit on the refresh button or press CMD + R / CTRL + F5</p>

</div>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'YOUR GOOGLE ANALYTICS ID']);
_gaq.push(['_setDomainName', 'YOUR DOMAIN']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, '500 Error', 'Error site Loaidng', 1]);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</body>
</html>

And share this anywhere you like.