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.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

There Are 15 Responses So Far. »

  1. 1 Mac Tips
    Wednesday, July 23rd, 2008 at 4:42 am

    This doesn’t seem to work for me in wp 2.6. It only seems to show the last 8 posts.

  2. 2 technology
    Wednesday, July 23rd, 2008 at 5:13 am

    thank’s for information

  3. 3 jbj
    Wednesday, July 23rd, 2008 at 7:11 am

    @Mac Tips: Try to set $posts_to_show =-1;
    It do works perfectly on my blog.

  4. 4 Jean-Baptiste Jung
    Wednesday, July 23rd, 2008 at 4:47 pm

    Oh Mac Tips, btw, I LOVE your website :)

  5. 5 Sulaiman Sabur
    Wednesday, July 23rd, 2008 at 8:40 pm

    A Little Help Here.
    What i do is;
    1.Create archives.php and uploaded it to my template directory.
    2. pasting the begining code archives.php
    3. Pasting the second template to archives.php
    4. Create Archives page.

    But it shows blank page Here :
    http://offshoreman.net/oil-gas-jobs/archives

    The part that i dont understand is…
    “Then, in Wordpress dashboard, create a new page, name it “Archives” (or whatever you want) and select Archive page as page template.”

    How to select Archive page as a page template?

  6. 6 Mac Tips
    Thursday, July 24th, 2008 at 3:24 am

    I managed to get it to work. A little work around.

    Thanks jbj. I’ve been a reader for catswhocode for a while.

  7. 7 jbj
    Friday, July 25th, 2008 at 8:35 am

    @Sulaiman: You’re almost done. Read this post for more info about pages templates. I also think this image shall help you.

    Good luck!

  8. 8 Sulaiman Sabur
    Friday, July 25th, 2008 at 9:40 am

    hi,
    TQ, with that I manage to assign page template to my Archives page.  But it is displayed not in a proper template format. Here is the Archives page

    http://offshoreman.net/oil-gas-jobs/archives/

    The page was displayed in a very plain.  Whereby my template displayed my page as follow;

    http://offshoreman.net/

    Hope you understand my english….
    BtW : you are the only Wordpress related tips that i subscribe.  Marvelous content!.

  9. 9 Jean-Baptiste Jung
    Friday, July 25th, 2008 at 1:05 pm

    The archive works, you just have to paste your header & footer info in order to have it working as the rest of your blog.
    I should have told it in the article, but the code to paste depends of your theme.

    Obviosuly Hack Wordpress is probably one of the best Wordpress tips sites available! But you should also check out <a href=”http://www.catswhocode.com”>my blog</a>, where I also provide Wordpress tips and tutorials.

  10. 10 Jaime
    Monday, July 28th, 2008 at 7:13 am

    Hey! Thanks for the tips but I am having so much trouble trying to assign the template to the page! Can you help me? There is only, and nothing about page templates!:

    Password Protect This Page
    Page Parent

    + Page Slug
    Page Slug

    Page Order

    Thank you!

  11. 11 jbj
    Monday, July 28th, 2008 at 10:51 am

    Hi Jaime,
    Did you read comment #7 and visited the links I gave? If yes, what’s your Wordpress version?

  12. 12 Jaime
    Saturday, August 2nd, 2008 at 7:14 am

    Hey. Thanks for the quick response. I’m using v2.6 (latest version of WP). If you’d like me to take a screenshot I’d happily do so :) thanks

  13. 13 Andy
    Saturday, August 9th, 2008 at 9:38 am

    Thanks a lot for this article, I just used it for making the archives on my site.

    I did have a little trouble finding the ‘page template’ part when writing the page, but after I created the archives.php file it popped right up between ‘page parent’ and ‘page order’ in the ‘advanced options’ section. I don’t know if that helps you Jaime, but it seemed to happen that way for me.

  14. 14 BOGDAN
    Sunday, August 31st, 2008 at 10:02 am

    Hy there. Thank you for the post.
    I’m wondering how can i also add a days before links to posts.. like this one
    http://indielabs.com/blog/archive/

    Thanks a lot!



Leave A Comment