Custom Error for WordPress

Tested up to 2.8.5

There’s nothing I do I hate more than finding an error after hours happening.

That was happening in one of my blogs quite often, and I couldn’t trace properly…

This WP hack will allow you to control the 500 error and been notified every time this happens.

How to?

First – Create in the same folder of you theme a file called error.php. In this file I recommend to you to add only HTML code with a friendly error message.

Second – Edit this file in your favorite text editor /wp-includes/wp-db.php

Third – Find this function “function bail($message)”

Fourth – Instead of the current function I recommend to comment the function and paste this (change what’s needed)

function bail($message) {
/*
custom error page hack
shows a custom error page and emails error instead of showing the default wordpress database error page
*/
   include('wp-content/themes/YOUR_THEME_HERE/error.php');
   mail('your@email_here.com', 'WordPress Error!', $message);
   die;
/* end custom error page hack */
}

This must be used careful and under your own risk. Also be aware of mass email sending/receiving.

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • Google Bookmarks
  • BarraPunto
  • Bitacoras.com
  • FriendFeed
  • Meneame
  • Netvibes
  • Reddit
  • StumbleUpon
  • Tumblr
  • Wikio
  • RSS
  • email
  • PDF
  • Print

Related posts:

  1. Error reporting for PHP
  2. Error in Open Classifieds 1.4.2 function isSpam() missing
  3. Speed up your WordPress
  4. WP-PageScroll, Plugin for WordPress
  5. Open Classifieds for WordPress – wpClassifieds

Leave a Reply

Follow me