How to: Create an Archive Page for your WordPress blog
Category: Themes and Tricks
- CSS We Are The Buzz




(5 out of 5) - Throw




(5 out of 5) - qmula




(5 out of 5) - Heartworker




(5 out of 5) - Decently Exposed




(5 out of 5) - Gmcosta




(5 out of 5) - DePo Masthead




(3 out of 5) - Sinklar




(3 out of 5) - Simple WordPress Theme - SimpleWP




(3 out of 5) - Arman Adhitama




(3 out of 5)
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 lyxia.org, 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.
If you want to use a plugin, you shall also give a try to Clean Archives, or Extended Live Archives, which allows numerous personalizations.
Do it yourself
Wordpress allows you to create page templates, so it’s possible to create manually an archive page. This is what I chose to do on my blog in English, CatsWhoCode.com.
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>Monthly archives</h2>
<ul><?php wp_list_cats('sort_column=name&optioncount=1') ?></ul>
<h2>Categories</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.
—
Related Articles at Hack WordPress:
- How To: Change the WordPress Author Archive Permalink
- How To: Blocking Your WordPress Categories and Archives From Google
- Popular Posts - March 2008
- Premium Theme: WP-Magazine 1.0 WordPress Theme
- Compilation of WordPress Hacks
- How To: Adding An Author Page To Your WordPress Blog
You are reading How to: Create an Archive Page for your WordPress blog. This post is the property of Hack WordPress © 2008.
Enjoy writing about WordPress? Get your blog more exposure by joining the Hack WordPress writing team!
Digg This! | Stumble This! | Add to Del.icio.us! | Google Bookmark It!
