In my opinion, all blogs should have an archive page: It allows your readers to quickly browse your blog and find what they’re looking for, and this page is also very good for SEO.
Here’s how to create this page on a WordPress blog:
Archive WordPress Plugins
There’s many plugins which allows you to automatically create an archive page. The good thing is that you’ll have (almost) nothing to do, and the bad thing is that you will not be able to customize it a lot, or you’ll have to edit the plugin files, which is sometimes a bit too hard if you’re not a developer.
On my blog in French, I use the Smart Archives plugin. Even if it gives me satisfaction, the loading time of the page is very long due to the amount of posts to be displayed simultaneously.
Do it yourself
Before starting to code, you’ll have to choose between two different kinds of archive page. The first one will list all your posts, and will allow a direct access to every article you wrote. The only bad thing is that when your blog will have many posts, the list may be a bit too long.
The second template, which is better for blogs that have been online since more than one year, will list your posts monthly and by categories.
Your choice is made? So let’s go coding!
First we’ll have to create a new file and name it archives.php. At the beginning of the file, paste the following lines:
<?php /* Template Name: Archive page */ ?>
This php comment define a name for our template, and will later allows us to select it on WordPress Dashboard, when we’ll create a new page.
First template: Listing all posts
<?php $posts_to_show = 100; //Max number of articles to display $debut = 0; //The first article to be displayed ?> <?php while(have_posts()) : the_post(); ?> <h2><?php the_title(); ?></h2> <ul> <?php $myposts = get_posts('numberposts=$posts_to_show&offset=$debut'); foreach($myposts as $post) : ?> <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> <?php endwhile; ?>
Second template: Archives by months and categories
<?php while(have_posts()) : the_post(); ?> <h2><?php the_title(); ?></h2> <h2>Categories</h2> <ul><?php wp_list_cats('sort_column=name&optioncount=1') ?></ul> <h2>Monthly Archives</h2> <ul><?php wp_get_archives('type=monthly&show_post_count=1') ?></ul> <?php endwhile; ?>
After you chose one of the templates I shown you above and pasted it to your archives.php file, you just have to upload it on your wp-content/theme/yourtheme/ directory.
Then, in WordPress dashboard, create a new page, name it “Archives” (or whatever you want) and select Archive page as page template.
That’s all! You now have an archive page, which is good for both your reader and search engines crawlers.