Tips, Tricks & Tutorials

WordPress Archive that *works*: StepxStep Guide and Plugins

September 21st, 2008

One of the advantages of using WP Archives page is the amount of information that it can provide to help the visitors easily browse your blog and find what they’re looking for. It can also act a your blog’s sitemap which is perfect for search engines.

Most WordPress themes already have archives.php template file in your theme’s folder. In this episode of WordPress series we are presenting some basic and advanced techniques to create a more user-friendly and more appealing archives page.

You might e interested to check other posts in this WordPress Series:

So lets get started, and don’t forget to subscribe to our RSS Feed as there is a small gift on its way.

Create Archives.php Template File

First, if you don’t have the archives.php file in your theme’s folder, create a new file and put the following code in it.

<?php
/*
Template Name: Archives Page
*/
?>
<?php get_header(); ?>
		
	<?php get_sidebar(); ?>
	
	<div id="content">

	<h2 class="entry-title"><?php the_title() ?></h2>

	<?php the_content() ?>

		<h2>Archives by Month:</h2>
			<ul>
				<?php wp_get_archives('type=monthly'); ?>
			</ul>
		
		<h2>Archives by Subject:</h2>
			<ul>
				 <?php wp_list_categories(); ?>
			</ul>
		
	</div>

<?php get_footer(); ?>

After that you need to create a new page and change the “Page Template” option to the new “Archives Page” template file.

Planning your Archive

Probably the most prominent ways to display data on the Archives page is by using either one or two of the following concepts:

  • Display all posts on the blog
  • A monthly(or yearly) list
  • Show all categories

1. Listing all Posts

1.1. Archives recent # of Posts

Displays archive list of the last twenty most recent posts listed by post title.

	<?php wp_get_archives('type=postbypost&limit=20&format=custom'); ?> 

1.1. Archives all Posts (Displaying Date, Category, number of comments, etc…)

We can create a more advanced archives page by using the loop. This will give us more flexibility to display all the info we need to show for each post listed (the published date, number of comments, catgory, and custom fields)

<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<ul>
    <?php $totalposts = get_posts('numberposts=200&offset=0');
          foreach($totalposts as $post) :
    ?>
    <li>
          <?php the_time('M j') ?> : <a href="<?php the_permalink(); ?>"><? php the_title(); ?></a>
		  Posted in: <?php the_category(', ') ?>
		  <?php comments_number('No Comments', 'One Comment', '% Comments' );?>
    </li>
 
    <? php endforeach; ?>
</ul>
 
<?php endwhile; ?>
1.2.WordPress Plugins to list all posts

-WP Simple Sitemap

WP Simple Sitemap is a WordPress plugin that automatically lists all your posts with a page number navigation. You can view a demo here.

WordPress Archive


-SRG Clean Archives

This plugin lists the Month / Year, shows total post count for the month, the day of the month the article was published, the title of the article and the number of comments that have been made on each article. Also you can toggle on/off the moo.fx for collapsing months. You can view a demo here.

WordPress Archive


1.3. Smart WordPress Archives Solutions Listing all Posts

-CSS-Tricks

WordPress Archive


-Web Designer Wall

WordPress Archive


2. Display monthly or Yearly Archive

2.1. Template Tags/wp get archives

The wp get archives is a function that displays a date-based archives list. The parameter arguments are given to the function in query string format. This tag can be used anywhere within a template.

<?php wp_get_archives('arguments'); ?> 

Archives Monthly:

Displays archive list by month

	<ul>
		<?php wp_get_archives('type=monthly'); ?>
	</ul>

Archives Daily:

Displays archive list by date, displaying only the last fifteen days.

	<ul>
		<?php wp_get_archives('type=daily&limit=15'); ?> 
	</ul>

Text to be placed after and before the link

Text to place before or after the link when using the html or custom for format option.

<?php wp_get_archives('before=&laquo;'); ?>
<?php wp_get_archives('after=&laquo;'); ?>

Display number of posts in an archive

Display number of posts in an archive (1 – true) or do not (0 – false). For use with all type except ‘postbypost’.

<?php wp_get_archives('show_post_count=1'); ?>
<?php wp_get_archives(%u2019type=monthly&show_post_count=1%u2032) ?>

Dropdown Box Archive

Displays a dropdown box of Monthly archives, in select tags, with the post count displayed.

<select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'> 
  <option value=\"\">\
  <?php echo attribute_escape(__('Select Month')); ?>
  </option> 
  <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> 
</select>
2.2. WordPress Archives Plugins (Sorted by month, year)

-Clean Archives Reloaded

Clean Archives Reloaded generates a list of all of your posts, sorted by month. It’s enhanced with Javascript to allow collapsing and expanding of months. A demo can be found here.

WordPress Archive


-WordPress Heat Map plugin

The WordPress Heat Map plugin provides you with three new template tags for displaying a heat map (aka weighted list) of your categories, tags and monthly archives.

WordPress Archive


-Smart Archives for WordPress

Smart Archives is a rather simple WordPress plugin that will allow you to display your archives in a much “cleaner” format. Everything on the page is hyperlinked (years, months, posts). You can view a demo here.

WordPress Archive


3. Archives Ordered By Category

Display all the categories of your blog and show post count in each category.

<?php wp_list_cats('sort_column=name&optioncount=1') ?>
3.1. WordPress Archives Plugins (Ordered By Category)

-Latest Post from each Category plugin for WordPress

This plugin displays a list of the latest post from each category of your WordPress installation. In the plugin’s options page you can choose the sort order, show or hide the dates, select the date formatting, show the first X characters of the content, display a link to the comments, and show comment counts, as well as other options.

WordPress Archive


-Extended Live Archive

This plugin implements a dynamic, AJAXified way of digging into the archives of a blog. You can check a live example here.

WordPress Archive


Further Readings on Creating your WordPress Archives

The jungle is alive: Be it a collaboration between two or more authors or an article by an author not contributing regularly. In these cases you find the Noupe Editorial Team as the ones who made it. Guest authors get their own little bio boxes below the article, so watch out for these.

Tags:

42 comments for „WordPress Archive that *works*: StepxStep Guide and Plugins
  1. Nathan Beck on September 22nd, 2008 at 12:54 am

    Yeh I think I’m going to go for this. Even though my site’s only got 7/8 months of posts, there’s over 80 of them and anything older than the front page sees little traffic, this may help that.

    Thanks Noura!

  2. klou on September 22nd, 2008 at 1:47 am

    Thank you for this wonderful post :)

  3. John on September 22nd, 2008 at 4:06 am

    Great post! Very comprehensive. Thank you.

  4. Shazza on September 22nd, 2008 at 5:42 am

    Indeed great tips! Thanks for the time you spent writing this excellent post!

  5. Mihai on September 22nd, 2008 at 5:43 am

    Great post again. Some of these will come in handy.thanks

  6. pickupjojo on September 22nd, 2008 at 6:05 am

    Nice tips, I think I’ll change my archives… It looks so bad.

  7. Matt on September 22nd, 2008 at 6:30 am

    Nice work, I am in need of an archives page for my site as well, so I think I will have to use the home grown approach you wrote up. Not a huge fan of plugins.

    Thanks!

  8. Ian Blackford on September 22nd, 2008 at 6:33 am

    A good archives page is an essential – so many times I have been discouraged from searching in someones archive. I ought to post then a comment telling them about your article.

  9. Rahul on September 22nd, 2008 at 8:44 am

    Cool tricks. I think I should also try some of these tricks for this blog http://www.hamroawaaz.com/ as well.

  10. Chris Coyier on September 22nd, 2008 at 8:48 am

    Archives are a tricky thing to do right! I do like my plugin I’m using, but I think I really ought to do more with it. I like the idea of listing the date and # of comments in there too.

  11. Dainis Graveris on September 22nd, 2008 at 2:16 pm

    Huh, i better just use some plugin, I am sure that will do better as I could..:) I’ll use this list to help me edit that, thanks mates!

  12. Umut on September 22nd, 2008 at 10:31 pm

    Something I was planning to implement for a while but didn’t have an idea how to do it.

    Thanks very much..

  13. JoeNuts on September 23rd, 2008 at 12:40 am

    Great collection, but I see a couple of problems.

    Which one is the best, or of that is not possible, which one is suitable for different purposes such as better navigation through archives, better PR flow within the site, overall better SEO.

    I see one with javascript – is it just enhanced with javascript, and how does that go with the crawlers?

  14. Taote on September 23rd, 2008 at 1:13 am

    How could I exclude certain categories when displaying monthly or yearly archive links?

    Thanks!

  15. Keith on September 23rd, 2008 at 4:39 am

    One of the things that I like about WordPress is its archive system. The PHP functions written for WordPress is simply so easy to use. Not to mention, it’s only a small blog application, which can be enhanced further into a CMS.

  16. Jim Jenkins on September 23rd, 2008 at 4:47 am

    Wow dude, I think you summed it up nicely.!

    Jiff
    http://www.anonymize.us.tc

  17. cssbit on September 23rd, 2008 at 5:27 pm

    i love this function
    thanks

  18. Jazzy on September 23rd, 2008 at 10:36 pm

    thank you for this post, i needed this!

  19. Vladimir on September 24th, 2008 at 2:52 am

    Too bad you left out Snazzy archive. Demo here
    http://www.prelovac.com/vladimir/archive-spec

  20. design on September 25th, 2008 at 9:32 pm

    Good article, nice job!

  21. insic on September 29th, 2008 at 7:16 am

    ive been looking for this for a while and now its in noupe. thanks for this guys, it helps a lot.

  22. samehzone on October 3rd, 2008 at 2:07 pm

    great
    but i have to ask is this will help me with the seo to get more traffic ?

  23. SaijoGeorge on October 3rd, 2008 at 7:45 pm

    gr8 tutorial mate ..

  24. Blograzy on October 5th, 2008 at 7:01 am

    brilliant explanation. Thanks. I will make it soon for my blog. :)

  25. uk mobile phone deals on October 10th, 2008 at 2:14 am

    Great post! Brilliant description. Thanks so much

  26. Bo?az Turlar? on October 14th, 2008 at 5:29 am

    Te?ekkürler

  27. Bo?az Tekne Turu on October 14th, 2008 at 5:29 am

    Te?ekkürler

  28. Osterello on October 20th, 2008 at 3:02 am

    Great post! thanks

  29. Syahmi on November 29th, 2008 at 2:15 am

    Nice info. Thanks for sharing.. :)

    • Advenda on December 26th, 2009 at 2:44 am

      nice info. i’ve been looking for this tutorial for long time. thanks

  30. kyle steed on January 13th, 2010 at 7:30 am

    Here’s a little helpful tip I learned after following this article. I wanted to add all my posts like it says up in 1.1 – Archives all Posts (Displaying Date, Category, number of comments, etc…) – but I ran in to a problem with displaying the comments.

    So here’s how I fixed it. Instead of using:

    I used:

    And that seemed to work great for me. Hope this helps someone else.

  31. kyle steed on January 13th, 2010 at 7:33 am

    Ugh. Ok it didn’t add my code. Let me try something else. So here’s the original code from the article that it says to use to pull in the posts:

    and this is what I used instead:

    Notice I am only pulling in from one specific category here as well. That’s because I wanted to show three different columns in my archives, based on what category the post are in. I thought it would be a cool way to organize the archives.

    You can see them here: http://kylesteed.com/archives/

    Thanks.

  32. kyle steed on January 13th, 2010 at 7:35 am

    Ok well obviously either I’m doing it wrong or you can’t post code in to these comments. Sorry. Here’s a screenshot of how I fixed the problem with not being able to display comments in my archives. Hope this can help someone else. http://cld.ly/3011qy

  33. Satya Prakash on November 13th, 2010 at 4:49 pm

    All plugins are rubbish plugins mentioned here. I have tried clean archives reloaded , wp-archive and one other. No, one works correctly.

    • Jaylin on June 23rd, 2011 at 1:29 pm

      That addresses several of my concerns atucally.

  34. infinets3 on January 27th, 2011 at 12:13 pm

    good

  35. bono on February 9th, 2011 at 6:25 pm

    really helpful wp archive tips. saved me some time. thanks

  36. Deepak Rajpal on May 15th, 2011 at 6:36 pm

    Exactly what i was searching for… thanks noupe..
    its my show time for custom post types with categories wise archieve(with image)

  37. Bogaz Turu on June 23rd, 2011 at 3:53 pm

    Keep up the good work. Thanks for sharing.

  38. aditia on August 23rd, 2011 at 8:52 am

    thanks man, need to adding archive page on my blog, the great thing is even in wp 3 the code still work

  39. Nadeem Khan on December 28th, 2011 at 6:28 pm

    very very interesting and useful stuff !!!

  40. Edouard on February 17th, 2012 at 9:53 pm

    Hi, you seem to be an expert on archives.. My new wp 3.3.1 install will only display one post for a tag in the Archives for Tag page… I have like 20 posts with the tag “test” and it only displays one. Why? Ehat should i look for? Whre should i look (which files?)
    Thanks for any help you could give me…