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.

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>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.

Jean-Baptiste Jung is a blogger/web developer/web designer who lives in the French-Speaking part of Belgium. Jean-Baptiste maintains two blogs: Cats Who Code.com where he and other authors write about Web Development, Web design, Blogging tips and WordPress, and WPRecipes.com where Jean shares useful WordPress snippets on a daily basis. When he's not blogging or having fun with codes, Jean loves to spend time with his wife and cat, and traveling everywhere he can.

  • http://www.mactricksandtips.com Mac Tips

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

    • http://banana.munki.se Emmy

      same for me in 2.9…Emmy

    • http://nsiteful.com/ Jeff

      For those who saw unexpected results when using the first template, the culprit is the set of SINGLE QUOTES. If you replace the SINGLE quotes with DOUBLE quotes in the get_posts() string, it’ll work.

      PHP won’t evaluate the variable since it is within a single-quoted string. Thus (I believe I’m right about this), the get_posts() call defaults to show the number of posts configured in the “Blog pages show at most” field of the “Reading” section of the “Settings” subpanel.

      Change this:
      $myposts = get_posts(‘numberposts=$posts_to_show&offset=$debut’);

      … to this:
      $myposts = get_posts( “numberposts=$posts_to_show&offset=$debut” );

      • khamsani

        Thanks for this :)

  • technology

    thank’s for information

  • http://www.catswhocode.com jbj

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

  • http://www.catswhocode.com Jean-Baptiste Jung

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

  • http://www.offshoreman.net Sulaiman Sabur

    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?

  • http://www.mactricksandtips.com Mac Tips

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

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

  • http://www.catswhocode.com jbj

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

    Good luck!

  • http://www.offshoreman.net Sulaiman Sabur

    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!.

  • Pingback: WordPress Weekend Resources - July 25, 2008 | Theme Lab

  • http://www.catswhocode.com Jean-Baptiste Jung

    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.

  • Jaime

    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!

  • http://www.catswhocode.com/ jbj

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

  • Jaime

    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

  • http://hideyourarms.com Andy

    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.

  • BOGDAN

    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!

  • Pingback: 100+ Killer Wordpress Resources | Steffan Antonas' Blog

  • http://www.blogsdna.com Blogsdna

    There is some mistake in headings of “Second template: Archives by months and categories”
    Code – wp_get_archives(‘type=monthly&show_post_count=1′) is for Monthly Archives but heading is given Categories
    Same is with Monthly archives but heading is given Catagory.

  • http://kyleeslick.com Kyle Eslick

    @ BlogsDNA – Good catch! I have updated the post. :)

  • Pingback: 8 tips to enhance your WordPress blog SEO

  • Bingu

    nice tip.
    I should make one for my blog now.

  • http://www.sinobeta.com RocyHua

    It is So and SEO Cool!
    Thanks!

  • http://www.donal.ie Donal

    Thanks for this, should sort me out.

    In case you haven’t noticed, wp_list_cats has been deprecated and replaced by wp_list_categories.
    http://codex.wordpress.org/Template_Tags/wp_list_cats

  • zulva

    ho ho ho..
    finally i find my article that i loked for..

  • Iwan Susanto

    Thanks for your tip..

    So now, I will use the archives.php file to make the archive page.

  • Pingback: creativehedgehog | victories in website crafting

  • Pingback: Tips to enhance your WordPress blog SEO | CSS Experiments

  • http://virgintech.org VirginTech

    Would love to give it a try!

  • http://www.hellboundbloggers.com/about S.Pradeep Kumar

    I tried this tutorial, it worked like a charm ! But it displays only 10 articles ! ?

    Any idea ? To show all the posts ?

    I tried the first template listing all posts.. you can check my archives now…

    • Softslas

      Try this.I think your problem will be solved.
      Ctreate the custom Archive page for your blog

  • http://www.hellboundbloggers.com/about S.Pradeep Kumar

    Hey I finally solved the problem.. now my archives is fine ! ;)

    Thanks for this tutorial ! :)

  • justin

    Hellow, I’m trying to show a bit of content as for each archive. So like the first 20 words of the article as well for each archive shown.

    How would you go about coding that up?

  • Softslas

    1.Open the function.php file of your theme.Then copy the following code and paste there.

    function excerpt($num) {
    $limit = $num+1;
    $excerpt = explode(’ ‘, get_the_excerpt(), $limit);
    array_pop($excerpt);
    $excerpt = implode(” “,$excerpt).”…”;
    echo $excerpt;
    }

    function content($num) {
    $theContent = get_the_content();
    $output = preg_replace(’/]+./’,”, $theContent);
    $limit = $num+1;
    $content = explode(’ ‘, $output, $limit);
    array_pop($content);
    $content = implode(” “,$content).”…”;
    echo $content;
    }

    Now Find Out the line containing the following code from the above which you created earlier.

    /* :<a href=””> */

    Replace it by

    /* :<a href=””> */

    Do not use /* */

    For more details visit HERE

  • Pingback: 10 Ways to Customize and Personalize your Wordpress Blog | Pro Blog Design

  • Pingback: wordpress düzenleme ve ki?iselle?tirme yollar? « Bay Bedava – Netten Ba?l?klar

  • Pingback: wordpress düzenleme ve ki?iselle?tirme yollar? | Teknoloji Soka??

  • http://tech4eleven.com cory

    Used the Clean Archives plugin. Its very nice actually.

  • http://xiawa.my Xiawa

    thanks so much, it works :D

  • http://www.websidual.com Create a Blog site

    Creating an archive page is important. Especially so your content can be at the fingertips of your readers. Thanks for the tutorial on setting one up. I’m going to have to add one to my blog.

  • Pingback: 10 Ways to Customize and Personalize your Wordpress Blog | SEO & Web Design

  • Pet Society Help

    Thanks for the tutorial, really helped me finally make an archive page! Quick and straight to the point!

  • http://qwertyweb.blogspot.com Ajinkya

    can you suggest it for blogspot blogs too , that would be ausumn , i mean just like wordpress , by creating link to archieves

  • http://www.anneliesje.nl Annelies

    Great job explaining the lot, but, after creating an archives page which is sorted by month, i didn’t get any nice results. It sure shows the months and links, but when i go to a month, i’m being redirected to the front page, but the url shows something like site.com/2009/11, so there’s no content with posts from that month there. How do I do that? I’m kinda green on this topic, so some explanation would help me a lot! What i want is after someones goes to a month, a page with posts for that month is shown…

  • http://phpstone.com frePerl

    Thanks,helps a lot

  • http://www.twitter.com/studwithswag knowledge

    Worked perfectly. Thanks for the info.

  • Pingback: 65 Of The Best WordPress Tutorials « Junkiee.Net

  • Comet

    I know this post is a couple years old, but I wanted to thank for you giving us this information. Extremely helpful! I really appreciate it!

  • http://www.lonelyschnozz.com Tyron

    I had problems with the first hack as my archives page was displaying the amount of posts set in “blog pages show at most” in the reading settings. To fix delete:

    Then change:

    $myposts = get_posts(‘numberposts=$posts_to_show&offset=$debut’);

    to:

    $myposts = get_posts(‘numberposts=-1&orderby=post_date&order=DESC’);

    This will display all your posts and will over ride the posts per page limit.

    • http://www.pzfantasyfootball.com PZ

      Tyron I’m having the exact same problem but your post says

      “To fix delete:” and then its blank!!

      What do I have to delete?

  • Pingback: Bookmarks for May 16th through May 18th « Peng’s Blog

  • http://successfultransformation.com Jacob Cassidy

    Thanks for posting this… and for everyone who added to the code in the comments. I was able to make my automatically updating archives page in a breeze with this (I was manually adding to it every time I posted before).

    Cheers,

    Jacob

  • http://www.ostheimer.at/ Andreas Ostheimer

    In the middle of reading it – minor thing: it is archive.php not archives.php, right?

    • http://lifepath4u.com Andy Badidis

      your template should be archives.php. By default arhive.php is the sidebar widget.

  • http://lifepath4u.com Andy Badidis

    I have this problem:

    I use the 1st template by the way.

    I put my blog page to show only 3 posts. The arhives page shows only these last 3 posts. What can I do to make it show the rest of the posts?

    • http://lifepath4u.com Andy Badidis

      also I want to ask how can I put a sidebar just as the other pages? when I put the sidebar code it drops it below or above the Arhives and makes it look ugly

  • http://anoveledit.com Beth

    Thanks for this. The article and thread gave me two pieces of information I didn’t find in other sources on this topic–that archive.php and archives.php are two different files and that adding the template title is what makes this appear in the template list (which you don’t have/can’t see if your WordPress theme has only the default template).

    That’s the information I was looking for.

  • http://www.realtimetricks.blogspot.com Irfan | RealTimeTricks

    Will you also tell how to make one in bloggers blog?

  • http://www.dreambloggers.com Rajan Balana

    Can anyone tell me , How i can use it in thesis theme ?

  • http://www.exinkai.com/ Ryan

    is there any easy method than this to make an archive page ?

  • Mahlah

    Thank you! This is exactly what I needed. :-)

  • Mahlah

    If you want to get rid of the category base in the url (which shows up when you are in sub-categories), this is the only plugin I found to not break the archives template, so thought I’d share:

    http://wordpress.org/extend/plugins/wp-no-category-base/screenshots/
    :-)

  • http://itinfoz.com Navin

    i already have the archive page btw nice post.

  • Michael

    I don’t see an Archive on your CatsWhoCode.com site. Only a the standard list of blog posts.

  • Barcelo Jandia Mar

    Thank you! This is exactly what I needed also.

  • rabindra lamsal

    Thanks for info… I was looking for it…Finally!!

  • http://www.reiseberichte.at Thomas

    Thanks for such a lot of interresting information!

  • chellie

    Hi there. I posted in the code and added it to my directory however on the actual page, there is no option for me to choose…I don’t have the option to select template. Any ideas as to what I can do? Thanks.

  • chellie

    THANK-YOU. I copied your code exactly and then I noticed there was a file named archive in the directory so I copied it, just in case and replaced that page with your page and yay…I now have an archives page instead of having it on the sidebar. Thanks a BUNCH…

  • http://academicwriterjobs.com ahmadshorif

    I need a plugin that will show calender and when i click a date of the calender then it will show the post of the pages of the specific category.

    Is there any plugin like something that ?
    But above code will helpful for my future task.

  • Junaid

    I want to make an archive page like instantshift has made… see the following link
    http://www.instantshift.com/archive/

    Please let me know if you can help me.
    thanks

  • http://silvaniblog.com Azubuike

    The tutorial is very useful one.

    My question now is, what is the difference between archive page and sitemap page?

    Thanks

  • http://www.outance.com/ Outance

    Thanks for tutorial… Archive page is very important for end user to find post.