Fine Tuned 404

This post is part of a series (Wordpress Theme Tips):

  1. Storing a Query
  2. Ajax Usability: Tab History
  3. Semantic Details
  4. Fine Tuned 404

Note: This post is over a year old. You may want to check later in this blog to see if there is new information.

As part of the Circle Six redesign, I culled the portfolio and in the process broke just about every link that Google had indexed. A new sitemap and some redirect pages are taking care of SEO, but in the interim, a lot of visitors are getting 404 pages. So I borrowed a tip from the blog and added a suggest feature to the C6 404 page

The first step was to set up the Wordpress database for a full text search. This is relatively simple and most easily accomplished by installing the Related Posts plugin and running the install script. I’ve never had the script fail, although it supposedly does sometimes and offers instructions for completing the task manually through SQL.

Next we just want to add some code to the 404.php file in our theme directory that will break apart the URI that was entered (or linked from another page such as Google), and run a search for the resulting words. Here’s the code for the current 404 page on the Circle Six site. The search code comes directly from the Related Entries plugin, which I just wanted to customize slightly:

404 Page with Search

[The requested file http://blog.circlesixdesign.com/wp-content/uploads/404withsearch2.txt could not be found]

Now when a broken link comes into the site, if the portfolio piece is still part of the site it usually guesses what they were looking for and offers a link to the piece. It seems to direct the traffic pretty well. After the search suggestions, it of course offers a search box. I chose not to offer a full sitemap on the 404 page, although that is certainly a possibility.

» » » » » » » » »
  1. AskApache 09.11.07 / 7pm

    Hey that is almost exactly what I was thinking when I built the AskApache Google 404 plugin. It uses the related posts, but the coolest thing is what you were saying about adding a search.. It adds Ajax-powered Google Search results! Check out the code you will like it.. :)

Have your say

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>




Safari hates me