Custom ‘useful’ 404 error page?

I read an article on Digg a few weeks back about making a successfully useful error page. Let’s eb fair about it, while the designers and programmers of the world may well understand the server error response code 404, for most it makes no sense – although I’d bet every web surfer in the world has seen at lease one. So why is it that most error pages are completely useless. If I hit an error page, I don’t want to be told that the server encountered a problem and have to mail the webdev, I want an explanation and a way to continue my navigation of the site. I had a think about this and decided I would make a simple custom page for this scribbish theme, none to difficult really and here’s what we did.

Open up the following directory on your server:


The path will be similar, no matter what theme you have installed, just replace ‘scribbish’ with the theme you are currently using. If you look at the bog standard error page, you will see that it just states the generic message within your template. We want to change this so that the user is

  1. Informed that some sort of error has occurred
  2. Given the option to go somewhere else

Part 1 is easy, just add the appropriate H1 and H2 tags, along with a couple or ‘p’ marks to write what you need to see.

Part 2 is a little bit more complicated, but not by much. I wanted to show the users the last 4 posts, perhaps that is what they were looking for. We need to know the function call in wordpress to display previous post along with a variable for the number we wish to show. A quick visit to the wordpress help pages and we find this little snippet.


My blog is having trouble posting php snippets with the correct tags. So you’ll need to surround the above code with php tags.

So insert that into your 404.php page, above the footer and possibly the sidebar depending on how your page is set out. Now when somewhere clicks or visits a part of your site with an error page, at least they may click back into your site and continue their search. You can change the ‘postbypost&limit=4’ to any number you wish, that determines how many of you recent post display.

Leave a Reply

Your email address will not be published. Required fields are marked *