How to Customize 404 Error Page

Your WordPress blog sends readers to a 404 Error page when they request for pages that don’t exist or have been moved. 404 means not found.

If your WordPress theme doesn’t have a 404.php template file, your blog redirects your readers to the front page in case of 404 errors. That might cause confusion because some readers will not know why they were sent back to the front page.

If your theme does have a 404.php template file, you can customize the error message and offer your readers some options on how to find the information they’re looking for or simply say, for example:

Not Found - This page doesn’t exist.

So what should you put in the 404.php file?

Simple, copy everything in the index.php file, paste it in the 404.php file, and then remove everything of The Loop, except for the Not Found area (after Else of The Loop).

An example of a customized 404:

<div class=”post”>
<h2>Not Found</h2>
</div>

Don’t copy and paste my codes. Type them out. Above the <div class=”post”> would be your headers and main column container or whatever you have that comes before the content. After the </div> would be your Sidebar and Footer or whatever you have that comes after the content.

You can take it a step further and give the reader a search form, right under the Not Found message:

<div class=”post”>
<h2>Not found</h2>

<div class=”entry”>
<?php include(TEMPLATEPATH . ‘/searchform.php’); ?>
</div>

</div>

I wrote a lesson on how to include the search form in the sidebar, but you can also include the search form in other places.

So now, Not Found is the title and the search form is the main content.

What's Next?
Related Posts

[…] Potato made a post about 404 pages for WordPress. His solution isn’t so bad, but if you want the real deal check […]

I’m going to add this to the list of things to do this month!

Nice information, i did see a lot of pages on other blogs i visited. i am not using wordpress though but worth enough.

Gray:

Great info here! Thanks.

One problem though… I customized my 404, but it does not show up in Internet Explorer. What do I need to do to make sure my 404 shows and not the IE default 404?

I don’t what browser you use matters. It should work in IE.

Gray:

Yeah, IE is ignoring my 404 page. I just read an article on how IE uses its own custom 404’s to hijack traffic from your site to an MSN search.

Another reason to not use IE, I guess!

Thanks for info.

You have an idea why I see id=”post-” just before the NOT FOUND???

Reply
Comment Policy
  • Theme support questions should be posted at the support forums.
  • Name and Email are required. Email is never published.
  • You grant this site perpetual license to reproduce your words and name/website in attribution.
  • Inappropriate comments will be removed at my discretion.
Close
Powered by ShareThis