WordPress Greatest Hits widget

One of my favorite best practices in blogging is the use of a greatest hits list on the home page. I find myself looking for this list every time I come across a new blog. With that in mind, I’ve been wanting to display a list of my favorite entries from this space for quite a while. The end result of this is a modified WordPress widget tool that you can use too.

I started by looking at the available tools. I could easily put something like this together with raw WordPress Template Tags coded into the template, but I wanted something more flexible, and portable. I find that hard coded modifications to templates get crufty over time – if you keep your code in plugins and widgets, you’ll have smoother upgrades, moves, theme changes, etc.

The default recent posts widget that comes with WordPress looked close to what I wanted, but I needed to be able to specify a category to display, and I didn’t want to build something from scratch. So after poking around a bit, I found Mike Jolley’s excellent tutorial and widget, My Recent Posts.

From there, I just needed to make a few changes to get what I wanted. I modified the widget control panel to allow me to specify a category id to show. I also modified the display code to not use wp_post2cat, which has been deprecated. You can see the modified plugin here:

Update: Hindsight being what it is, a recent look in the WordPress plugins directory shows an existing plugin that suits this need. James Lao built a plugin that shows posts from a specific category. From the looks of it, I like his plugin better than my hacked one.


  1. Gravatar Icon
    Posted January 28, 2008 at 10:16 pm | #

    Hi, Justin,

    Thank you for updating the Blue Anvil widget to work with WordPress 2.3! Unfortunately, it seems that 2.3.2 broke it again: The posts displayed are actually my oldest… Grrr. I had the same problem on the main page of my blog when I tried various ways of excluding categories from displaying (including Ultimate Category Excluder). I don’t know any PHP, so I have no idea how to fix this… I hope maybe you have some ideas…



  2. Gravatar Icon
    Posted February 1, 2008 at 8:22 am | #

    @Rachel – Have you tried Mr. Lao’s Category Posts plugin? I’ve found that one to work better.

  3. Gravatar Icon
    Posted April 2, 2008 at 7:20 pm | #

    I would love to see this plugin work for WP-2.5
    The “Category Posts” plugin can not display all recent postst in a list and exclude just one or more categories.

  4. Gravatar Icon
    Steve K
    Posted September 19, 2008 at 7:31 pm | #

    Thanks for posting the fix for Mike Jolley’s My Recent Posts widget!

One Trackback/Pingback

  1. [...] that there is a WP 2.3.2 bug that reorders posts since the same effect happens when using the My Recent Posts widget. Using the “order_by” statement didn’t help (I might’ve used it in [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

You can follow any discussion on this article with the RSS feed for this post.

About this article

Green Galoshes is a weblog written by Justin D. Henry. This entry was published on or around November 11, 2007.

Categories & Tags

This article is filed under blogging, bootstraps, code, tools. It is further described as , , , , .