db query for retrieving comments without any reply
Question
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?
Solution
this should work...
<?php
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);
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange