Who hasn't seen a 404 error page in his life? I'm sure there rarely is anyone. And you'll probably agree with me that 404 errors are boring—especially when you're looking for something that appears to have been moved.
This is why it is very important to have a custom and useful 404 page. In this recipe, I'll show you how to do it for your WordPress blog.
To achieve this recipe, you need a 404.php
file. Most WordPress themes actually feature this kind of page. If, for some reason, your theme doesn't feature such a page, simply create a php file named 404.php
and upload it to your wp-content/themes/yourtheme
directory. You don't have to add a Page template directive—WordPress automatically recognizes a file named 404.php
as a page designed to be displayed if a 404 error occurs.
In this example, we are using the 404.php
file from the default WordPress theme. If you open the file, you'll find the following code:
<?php get_header(); ?> <...