0

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?

3
  • It is unknown what the callback function do. Please review the question and edit it adding the missing code. Also, WooCommerce is off-topic here.
    – Max Yudin
    Jan 26 at 13:57
  • Hi, I tested the function after removing the callback and the issue persists if we have the page argument set. Without page argument, the comment order seems to be fine.
    – dc09
    Jan 26 at 14:06
  • 1
    Does the problem persists when you add &cpage=2 to the URL instead of passing 'page' => 2, ?
    – Max Yudin
    Jan 26 at 14:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.