WP_Comment_Query with 5 top level comments per page?
I'm trying to replicate the option in WordPress's settings page that says:
[x] Break comments into pages with ((5)) top level comments per page and the ((first)) page displayed by default
Right now I have the following comment query, but it only displays 5 comments, also counting the replies.
The behavior I want is 5 top-level comments, and all the replies those top-level comments might have. How do I achieve this?
Current Code
$args = array(
'post_id' = $post_id,
'type' = 'comment',
'status' = 'approve',
'number' = 5,
'hierarchical' = 'threaded'
);
$comments_query = new WP_Comment_Query;
$comments = $comments_query-query($args);
Output
Total of 5 comments
Comment 1
- Reply to comment 1
- Reply to comment 1
Comment 2
Comment 3
Desired Output
5 top-level comments and all their replies
Comment 1
- Reply to comment 1
- Reply to comment 1
Comment 2
Comment 3
- Reply to comment 3
- Reply to comment 3
- Reply to comment 3
Comment 4
Comment 5
- Reply to comment 5
Topic wp-comment-query comments Wordpress
Category Web