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
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…
Thanks!
Rachel
@Rachel – Have you tried Mr. Lao’s Category Posts plugin? I’ve found that one to work better.
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.
Thanks for posting the fix for Mike Jolley’s My Recent Posts widget!
One Trackback/Pingback
[...] 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