How to Add a Custom Database Error Page in WordPress

58

You ever remember seeing a screen like Error Establishing a Database Connection on your site. This can happen for various reasons, but often users don’t know that their site is down. Also that page itself looks pretty ugly in itself. In this article, we will show you how to customize your database error page in WordPress. We will also show you how to setup a notification for every time your website goes down due to a database error.

Open a new file and save it as “db-error.php”. Paste the following content inside that. Then upload the file in your /wp-content/ directory.

  <?php // custom WordPress database error page      header('HTTP/1.1 503 Service Temporarily Unavailable');    header('Status: 503 Service Temporarily Unavailable');    header('Retry-After: 600'); // 1 hour = 3600 seconds      // If you wish to email yourself upon an error    // mail("your@email.com", "Database Error", "There is a problem with the database!", "From: Db Error Watching");    ?>    <!DOCTYPE HTML>  <html>  <head>  <title>Database Error</title>  <style>  body { padding: 20px; background: red; color: white; font-size: 60px; }  </style>  </head>  <body>    You got problems.  </body>  </html>  

Source: CSS Tricks

If you want email notifications, then comment out the mail line. To comment it out, you have to remove // before the mail function. Feel free to customize the landing page however you like. Use these 404 design inspirations as a start.

Social Media Auto Publish Powered By : XYZScripts.com