I've been kicking around the best way to do this for a while now, so I figured it was time for a second opinion. I'm looking for a way to order my posts by most recent comment, or, if no comment, by post date. Think of it like basic forum sorting, posts with new comments go on top.
For the past few months, I've been using something close to what's described here:
http://stackoverflow.com/a/3947769. It's a big nasty query and it makes mixing in simple args or paging a little more complex than it needs to be. Way back before I went with my own query, I was looking at this plugin:
http://wordpress.org/extend/plugins/filter-by-comments/, which is something I'm now eyeing again. The download count and support threads are less than stellar, though.
My new plan is to get this done with post meta, accomplished in one of two ways: make my own meta key, like 'recent_activity", which I can hook to be updated on comment approval, or cheat and use something already present, like the post modified date. Normally that's updated when a post is edited, but since I've got almost no use for that, and since this field is an official 'orderby' parameter, I've been thinking about giving it a try:
http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters. Again, I'd just write a hook that updates the modified time upon comment approval.
So my question: what would you folks use to order posts by most recent activity? Mainly, I'd just love to move away from a raw SQL 'select' command and back into something a bit more comfortable. Ideas?
Clark