I selected only 2 levels of comment for my wordpress site.
How can I display the number of comment of the first level ? (Depth-1)
4 Answers
In the wp_comments table, if comment_parent
equals 0, it’s a first-level comment.
function get_num_toplevel_comments() {
global $wpdb;
return $wpdb->get_var("
SELECT COUNT(*)
FROM $wpdb->comments
WHERE comment_parent = 0
");
}