Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to display (for pages that use a particular page template) a list of custom post type objects filtered into 2 sets - those with comments, and those without comments. Each of these sets should display the last 10 of its type (ie the latest 10 posts with comments, and the lastest 10 posts without comments)

What's the best way of achieving this? So far, the easiest thing I've come up with is to just do a custom select with $wpdb. Hooking the query and adding a posts_join / posts_where filter doesn't seem like the best answer, as it's too global.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

And I should have done some searching before asking.

Looks like hooking the query might be the best way of doing this. Here's a good answer from StackOverflow with practically the same question.

share|improve this answer
    
The answer provided by postpostmodern on the SO topic was a good approach, i'm surprised it wasn't the accepted answer(far less fiddly then the SQL approach). –  t31os Feb 2 '11 at 15:39
    
@t31os - agreed, that's what I'm using –  anu Feb 2 '11 at 15:44
    
You know, this might make a valid feature request to, though it could be handled by a plugin, i can think of several reasons being able to select posts based on comment count might be useful. Be sure to sling a vote onto postpostmodern's answer if you're registered on SO(note: you can use the account you have here on SO to, it just won't carry across the rep)... ;) –  t31os Feb 2 '11 at 15:51
    
ah - forget to vote him up..done now! –  anu Feb 2 '11 at 16:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.