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,

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:

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

$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>
$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; ?>

<?php endwhile; ?>

Second template: Archives by months and categories

<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></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.

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching as a place to share hacks, tutorials, etc. Follow Kyle on Twitter @KyleEslick!

  1. Mac Tips says:

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

    • Emmy says:

      same for me in 2.9…Emmy

    • Jeff says:

      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” );

  2. technology says:

    thank’s for information

  3. jbj says:

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

  4. Oh Mac Tips, btw, I LOVE your website πŸ™‚

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

    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. Mac Tips says:

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

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

  7. jbj says:

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

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

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

  9. 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=””>my blog</a>, where I also provide WordPress tips and tutorials.

  10. Jaime says:

    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. jbj says:

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

  12. Jaime says:

    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. Andy says:

    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. BOGDAN says:

    Hy there. Thank you for the post.
    I’m wondering how can i also add a days before links to posts.. like this one

    Thanks a lot!

  15. Blogsdna says:

    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.

  16. Kyle Eslick says:

    @ BlogsDNA – Good catch! I have updated the post. πŸ™‚

  17. Bingu says:

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

  18. RocyHua says:

    It is So and SEO Cool!

  19. Donal says:

    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.

  20. zulva says:

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

  21. Iwan Susanto says:

    Thanks for your tip..

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

  22. VirginTech says:

    Would love to give it a try!

  23. S.Pradeep Kumar says:

    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 says:

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

  24. S.Pradeep Kumar says:

    Hey I finally solved the problem.. now my archives is fine ! πŸ˜‰

    Thanks for this tutorial ! πŸ™‚

  25. justin says:

    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?

  26. Softslas says:

    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);
    $excerpt = implode(” β€œ,$excerpt).”…”;
    echo $excerpt;

    function content($num) {
    $theContent = get_the_content();
    $output = preg_replace(’/]+./’,”, $theContent);
    $limit = $num+1;
    $content = explode(’ β€˜, $output, $limit);
    $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

  27. cory says:

    Used the Clean Archives plugin. Its very nice actually.

  28. Xiawa says:

    thanks so much, it works πŸ˜€

  29. Create a Blog site says:

    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.

  30. Pet Society Help says:

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

  31. Ajinkya says:

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

  32. Annelies says:

    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, 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…

  33. frePerl says:

    Thanks,helps a lot

  34. knowledge says:

    Worked perfectly. Thanks for the info.

  35. Comet says:

    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!

  36. Tyron says:

    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’);


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

    • PZ says:

      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?

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



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

  39. Andy Badidis says:

    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?

    • Andy Badidis says:

      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

  40. Beth says:

    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.

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

  42. Rajan Balana says:

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

  43. Ryan says:

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

  44. Mahlah says:

    Thank you! This is exactly what I needed. πŸ™‚

  45. Mahlah says:

    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:


  46. Navin says:

    i already have the archive page btw nice post.

  47. Michael says:

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

  48. Barcelo Jandia Mar says:

    Thank you! This is exactly what I needed also.

  49. rabindra lamsal says:

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

  50. Thomas says:

    Thanks for such a lot of interresting information!

  51. chellie says:

    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.

  52. chellie says:

    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…

  53. ahmadshorif says:

    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.

  54. Junaid says:

    I want to make an archive page like instantshift has made… see the following link

    Please let me know if you can help me.

  55. Azubuike says:

    The tutorial is very useful one.

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


  56. Outance says:

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

Trackbacks/Pingbacks »

  1. 100+ Killer Wordpress Resources | Steffan Antonas' Blog says:
  2. 8 tips to enhance your WordPress blog SEO says:
  3. wordpress dΓΌzenleme ve ki?iselle?tirme yollar? « Bay Bedava – Netten Ba?l?klar says:
  4. wordpress dΓΌzenleme ve ki?iselle?tirme yollar? | Teknoloji Soka?? says:
  5. 10 Ways to Customize and Personalize your Wordpress Blog | SEO & Web Design says:
  6. 65 Of The Best WordPress Tutorials « Junkiee.Net says:

Tweetbacks »