Creating your own Error 404 - page is both easy and might be extremely useful to your blog. The Error 404 page will display if a user comes from a search engine or somewhere else, and the destination page doesn’t exist anymore. You might have deleted it, or renamed it - as an example. Then, the Error 404 - page comes up. Error404: page doesn’t exist.
Wordpress have a hierarchy of templates. This means that if you NOT have a file called 404.php in your themes folder, Wordpress will display the file called index.php instead - and this is usually your frontpage. Of course, if the user searched for “blog competition” and comes to your front page - he might not understand much. So, thats why its useful with a error404-page where you could tell the user that he has searched for something that doesn’t exist anymore, and maybe try to lead him to something else on your blog.
You could also, just to make some quick cash, add some Adsense-ads - possibly gaining some profitable clicks. This will of course drive the visitor away from your blog, but you’ll earn some cash from it. Nice.
BUT HOW DO YOU MAKE A 404-PAGE?
This is the hard part. Well, its not hard, but it will require you to do some basic html and a FTP-upload to your themes folder. Ok, I certain you’ll manage it. So, lets start:
First, find a page template that is suitable. The file index.php usally will do the job. Find that file, open it in a text-editor, and try search for the code snippet called “the loop”. This code snippet shows your posts in a template. It looks something like this:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?><h1><?php the_title(); ?></h1>
<h2>Written <?php the_time('F jS, Y') ?> |
Filed in: <?php the_category(', ') ?></h2>
<?php the_content(' (read more..) '); ?>
<?php endwhile; ?>
<?php comments_template(); ?> <?php else : ?> <?php endif; ?>
Ok, this is the loop, it should look something like the code above, but it might differ somewhat depending on what theme you are using on your blog.
Just replace the whole loop with the thing(s) you want to display when a user tries to visit a page that doesn’t exist anymore. As an example, you could replace the loop with something like this:
- A message saying that the user have come to a page that doesn’t exist anymore. Usually: ERROR 404 - doesn’t exist. And then you could add a searchbox, saying: Try searching the archive!
- Add a couple of adsense-ads. Or some other affiliate program you use.
- If you have the very fine plug-in “Recent posts” you could add the code snippet of that plug-in here. And a search box under it.
- Write something about your blog, trying to get the user the read it every day. Add a link to your feed.
- A list of your best posts.
As you understand, the possibilities are endless. Add something that you think is best for your blog.
IMPORTANT!
After making the 404-page, you have to name it 404.php, and then upload it to your themes folder at your wordpress installation. The folder will typically be here: http://www.yourdomain.com/wp-content/themes/your-theme
Upload the file using a ftp-client, which you’ll find almost anywhere on the net. Try Download.com or just google “ftp-client”.
And of course: ALWAYS do a backup before you edit your theme-templates! Just in case you fuck up..
AND..
When you have set up your own error404-page, you could track how many users which actually sees it by using the 404-notifier plug-in written by Alex King. Useful plug-in.


















Categories:
Links:
Archives:
Meta:
Search: