Creating Effective 404 Error Pages for WordPress
Steven Snell designs websites and maintains a blog for Vandelay Website Design, where you can read his articles on design, marketing, blogging, and more.
Some visitors are inevitably going to come across 404 error pages on your site, regardless of how careful you are about preventing and correcting dead links. All it takes is a visitor making a typo when entering a URL or another blogger or webmaster incorrectly creating a link to one of your pages.
Error pages don’t have to be terrible experiences for your visitors, but you need to be prepared for the situation and make the necessary changes as soon as possible. Fortunately, WordPress users have a lot of options and potential for their 404 error pages.
Many WordPress themes already include specific 404 error messages, however, some themes do not. Even if your theme does include a 404 file, chances are it could benefit from some customization. Rather than simply displaying a non user-friendly message, why not try to provide the visitor with some help in finding the desired page/post?
If your WordPress theme includes a 404 file it will be contained in the theme’s folder and named 404.php. You can easily change the message that appears or add to it by editing the 404.php file. For example, you may want to add links to some of your most popular posts, or to your category pages. If your theme already includes a search function consider encouraging visitors to use the search to find what they are looking for. If your theme doesn’t already include a search function, consider adding one to make it easier for visitors.
If your theme doesn’t include a 404.php file, creating one is pretty simple. Of course the first thing you want to do is create a new file in your theme’s folder and name it 404.php. One option to create the page is to copy the code from you index.php file and then take out the part of the code that calls up recent posts. If you’re creating 404.php from scratch without using index.php, you’ll want to enter the following code to pull up the header, sidebar and footer:
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
After <?php get_header(); ?>
you’ll enter the code for whatever div
you use for the main body of your pages. For example, with the default Kubrick theme the code is:
<div id="content" class="narrowcolumn">
Inside that div
you can then enter anything that you want to appear on the 404 page.
Some other resources for WordPress 404 pages include:
- Guide to 404 Pages from the WordPress Codex
- 404 Search Function for WordPress
- Dunstan-Style Error Page Plugin
- 404 Notifier Plugin
- Doug Karr’s 404 Suggestions
Adnan's Points:
As an example of what you can write on your 404 page, checkout Blogtrepreneur's version. This came with the theme and gives the reader easy-to-follow instructions in order to help them navigate and recover from their error.
Better 404 pages insert humour to try and cheer up the visitor and make them smile. A very cool 404 page which I came across is by Michael from ProBlogDesign, who wrote a poem - very thoughtful!