Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

what is a query for selecting a list of comment id's that have not had a reply yet so I can use it to iterate though each comment id and echo out the post it is on and the excerpt of the comment along with the author name, url and how many comments?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

this should work...

global $wpdb;
$sql = "SELECT comment_ID FROM ". $wpdb->prefix ."comments WHERE comment_parent = 0 AND comment_ID NOT IN(SELECT comment_parent FROM ". $wpdb->prefix ."comments);";
$results = $wpdb->get_results($sql);
share|improve this answer
actually I spoke too soon! it works but it brings back every comment that hasn't had a reply. what is a query for bringing back top level comments that haven't had a reply? –  CommentLuv Jun 5 '11 at 19:02

Your Answer


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.