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.

4 Comments