• What is TechTraction?

    Personal commentary on technology with a sprinkling of tech-tips and how-to articles

Quickly Add Archive Totals to Your WordPress Theme

Note: Despite last week’s vote regarding the value of the “by-month-archive’ section, I decided to go ahead and publish the following post (mostly because it was already written). Complete vote results and analysis will appear on TechTraction this Wednesday 7/4/07. Thanks for stopping by.

On Monday (6/25/07) I posted a short article describing how to add category totals to the category list displayed in your WordPress theme’s sidebar. Adding these totals was easy and a real benefit, in my opinion, for your site’s visitors. You can also add an archive total (assuming you are displaying a standard archive list in your sidebar) in much the same way. And while visitors might not find this total useful, it can help you, the site owner, get a quick overview of how you have been doing with site content from one month to the next.

Adding “show_count” to “wp_get_archives” to Display Archives Totals in the Sidebar

I’ve struggled lately with posting content to TechTraction on a regular basis. While I have no shortage of topics to post about, my day job keeps getting in the way. I’ve been working at ways to overcome this posting problem and one thing I’ve decided I needed is a quick overview of my content totals from one month to the next. Taking off on the category total idea, I decided to add an archive total to my sidebar. If that sounds like something you want to do, follow these simple instructions:

  1. Log into your WordPress powered site as admin
  2. Select Presentation from the menu bar
  3. Select Theme Editor from the Presentation sub menu
  4. Locate and select the sidebar.php file from the “theme files” listing on the right hand side of the screen
  5. Scroll through this file and locate wp_get_archives(‘type=monthly’). The parenthetical option “type” allows you specify the type of archive you want to display. Options include postbypost, daily, weekly, monthly (the default), and yearly. Most WordPress themes display monthly archives in the sidebar. To learn more about the wp_get_archives tag refer to the WordPress reference page on the topic.
  6. Follow the “type=monthly” setting, if one is present, with “show_count=1″ and join them together with an ampersand. The completed edits will leave you with one of the following two lines:
  • wp_get_archives(‘type=monthly&show_count=1′)

or

  • wp_get_archives(‘show_count=1′)
  1. Press the Update File button to save your changes
  2. View your site to review and confirm your changes

Similar to Monday’s post (6/25/07) outlining how to add category totals to your sidebar, adding archive totals is just as quick and easy. Site visitors might not care how many posts exist in a particular month; however, if you want to easily monitor your month-to-month posting consistency, then add an archive total to your sidebar’s archive list.

For more information about WordPress template tags, take a look at the developer documentation back at the WordPress.org web site.


Go Daddy $1.99 Domains 468x60

If you liked this post, subscribe to TechTraction's RSS feed or TechTraction's email feed

Filed under: How-To & Tech Tips

6 Responses to “Quickly Add Archive Totals to Your WordPress Theme”

  1. I hope you dont mind but Ive added your feed to my webmaster search site because i felt alot of the information you provide is relevant for webmasters and will be a good addition to our database.
    Keep up the good work

  2. Hi ozonew4m, thanks for the comment and thanks for adding me to the webmaster search site feed. I took a quick look at the site and it does seem to be a good fit for some of the posts I write here at TechTraction. Hopefully the feed listing will generate some additional traffic and new feed subscriptions. Thanks for the inclusion and words of encouragement.

  3. Nice & Simple! That’s how I like ‘em. Now if I could just get WP to write my posts.

  4. I hear you. I wish I could get WP to write my posts as well. :-)

    Thanks for the comment

  5. If I am not wrong, We have category manipulation plug-ins and we can handle them from there. I am confused a little but one more term, it is tag. How those can be useful for blogging and how can we use them. I think this is something related to tag clouds.

  6. Hi Hip Zone, this post is approximately a year old and was written originally for versions of WordPress available at that time (looks like I should place post dates more prominently near the post title — I apologize for that). As for the question about “tags” — as far as I understand tags within your own site are very similar to categories except with more ad-hoc flexibility. Outside of your site, however, tags are something that other services and sites leverage. For example, I believe Technorati picks up on “tags” and uses them to aggregate content from a variety of sources.

    Thanks for the comment and I hope my explanation of tags helped.