Building a post index at WordPress.com with archives shortcode

Guest post by Richard

arch-basicI discovered another one of those stealthy features that show up from time to time at wordpress.com without announcement. There is now an “archives” shortcode which will allow you to build a post index on a page by just entering the shortcode. Click the thumbnail at left to see an example of the basic shortcode (no options) that creates a lists all posts in your blog [*archives*]. (Note: I’ve put an asterisk at each end so the example code does not put an archive here in the post.)

arch-mo-lim-countWordPress has provided numerous options that you can use to control the display of your lists such as yearly, monthly or daily, and you can if you wish even limit the number of posts in each list. You can even combine options. Click the thumbnail at left to see a list monthly list limited to the past 12 months with the post count showed for each month [*archives type=monthly limit=12 showcount=true*].

You might have noticed in the images that there is a “Shortcode Archives” title at the top which is the actual title I gave the page during testing, so don’t let that throw you.

The other interesting thing with this new feature is that we can use the archives shortcode in text widgets, which will give bloggers another option over the archives and recent posts widgets we already have.

Look over the support document (linked in the first paragraph) for an more complete and detailed explanation of this new feature and give it a try.

[Edit: One of the CSS guru's who help out in the WordPress.COM forums from time to time discovered a couple other issues with the implementation of the code (a couple missing ending HTML tags), so there are a few bugs to iron out.]

Official announcement link.

23 thoughts on “Building a post index at WordPress.com with archives shortcode

  1. Pingback: Use the Display Posts Shortcode to Effectively Feature Content | one cool site

  2. Thank you very much, Richard and timethief. I’ve just added an Archive page. I didn’t realise it could have been so easily done. It makes searching much easier.

  3. Hi Timethief,

    This was a great post and tutorial and it solved my problem for finding a way to put all my articles in a title/drop down box.

    One question; I used the text widget option in my sidebar and in the blank drop down box under the title there appears a “dash.” Any way I can replace this “dash” with text or something, or just get rid of the dash?

    This was a great help to our blog since many people look for titles of past posts.

    http://thesilverpeopleheritagefoundation.wordpress.com

  4. Hello,

    I wonder if anyone can help me–I can’t get an answer from Support.
    I made an Archives (all posts) dropdown list in my left column, but my longer titles ran over into the wide middle column, so I deleted the list until I can figure out how to solve the problem.
    Is there a way to force the longer titles into 2-4 lines, so they stay within the thin left column? Thanks very much,
    Pam B

    • Pam, the width of the pulldown is determined by the length of the longest post title, and wordpress did not provide anyway to shorten the pulldown or force line breaks in the post titles. I expect something could be done with the paid CSS upgrade, but it may end up cutting off post titles longer than the width set for the pulldown.

  5. I was using a plugin to generate a sitemap, but it looks like this will do the same thing (minus pages). I’ll make a note to try this out and see if I like the non-plugin approach better.

  6. Richard, is there any shortcode to display posts relating to a particular category on the blog?!

    And congrats for discovering it before the official WP announcement.

    • Okay Richard, I read your replies to worddreams better late than never. You may ignore my query and thank you. I’m waiting for the future when post ratings will show on main page and a shortcode for category will be available. :)

    • It is quite neat. I wish there was a way go do it by category as well, but Nick at Automattic said that the function they are using does not have a filter for categories, so it would be quite a bit of work to implement that, but that option may show up in the future.

  7. Thanks for the info! I didn’t like the format of the previous archives page, so I created my archives page list with basic html hyperlinks. I’m going try this out and see how this works. Sounds like a time saver.

    • This is definitely better than having to do it manually. The only thing I would like is more control over the format, but with the “shortcode” solution it is more difficult to implement formatting.

  8. Wow. It occurs to me that with the addition of options for archive by tag and/or category and display order, this thing could be used to automatically generate the TOC for my blog that I’m now doing manually! Good find!

    • I think there are a lot of people out there that have been “rolling their own” and with this being dynamic, it certainly will lessen your blogging load.

  9. This is a useful post. I can’t say I understood it exactly as I am not very tech savvy but the instructions seem pretty simple. I am bookmarking this post so I can refer to it when I want to do this shortcode.

    • Once you actually use it I think it will become more clear. The options take a little thinking, but a little playing about with things and you will get it.

Comments are closed.