I am using the following code to output comment html:
$args = array (
'post_id' => 805,
'status' => 'approve'
);
$comments = get_comments( $args );
$comments_html = wp_list_comments( array(
'page' => 2,
'echo' => false,
), $comments);
I used error_log
to output $comments
and it seems to be in descending order, which is correct as the setting for comment display in Settings > Discussions
is "Comments should be displayed with the newer comments at the top of each page"
.
However, on running wp_list_comments
, the order gets messed up.
I have set 30 comments to be displayed per page. For products with less than 30 comments, the sorting seems to be by date in descending order. However, for products with more than 30 comments (and with comment pagination), the sorting order is messed up.
How to make this work with wp_list_comments
and comment pagination?
callback
and the issue persists if we have thepage
argument set. Withoutpage
argument, the comment order seems to be fine.&cpage=2
to the URL instead of passing'page' => 2,
?