How to create a useful 404 page in WordPress

A 404 page (Page Not Found error message) is a page a user gets to see when they attempt to access a part of a website or WordPress blog that does not exist. Either the page has been (re)moved, the user clicked a broken link, or maybe they misspelled a word in the URL.

How to create a useful 404 page in WordPress

Often, a 404 page has nothing interesting to offer the user, causing them to just click away from the page again. This is a waste. Why not try and customize your 404 page in a way it invites them to look around your website or WordPress blog, or help them find what they were looking for?

What a custom 404 page should contain

The idea is to try and get the visitor to stay on your blog, here are some ways to try and achieve this.

  • Make sure your 404 page has the same look & feel as the rest of your blog.
  • Provide the visitor with a clear and friendly message explaining that the page they were looking for could not be found.
  • Include a search box for the visitor, so that they can try and find the page they were looking for.
  • Have some of your latest and/or most popular blog posts show up on the 404 page.

Where do I find the 404 page template in WordPress?

Your theme should come with a 404 template (404.php). You can either edit this file manually or edit it when logged into your WordPress dashboard as admin. (Appearance -> Editor).

How to display recent WordPress blog posts

To display a list of recent blog posts, you can use the following code:

<ul id=”recentposts”>
<?php get_archives(‘postbypost’, ’15’, ‘html’, ”, ”, FALSE); ?>
</ul>

You can change the number (15) to any number you want – this is the number of posts that will be listed.

Of course, you can also manually edit your WordPress 404 page, you could add a nice image, include links you think may be of use to the visitors who stumbled upon your 404 page, and so forth.
All in all, editing your 404 page in WordPress is not hard at all, so go and make something nice and useful out of it!