$reverse_top_level works the opposite way according to Codex?

The Codex for wp_list_comments states $reverse_top_level
(boolean) (optional) Setting this to true will display the most recent comment first then going back in order.

For my it is actually the opposite way. false option will display the latest comment as the first one and true option or if the option is not used at all will the last one. The same applies if comment pagination is used or is not used.

Read More

Similar behavior applies to reverse_children option. If false or not used at all the latest child is the first one.

Code used along with WordPress 3.6.1 on TurnKey

    $comments =     get_comments(array(
        'number' => $get_comments_number_approved,
//          'offset' => 10,
        'post_id' => $post_id,
        'status' => 'approve' ,
        'orderby' => 'comment_date_gmt',
        'order' => 'DESC'
    ));

        wp_list_comments(array(
            'reverse_top_level' => false, //Show the latest comments at the top of the list
            'reverse_children' => false,
            'page' => $page_number,
            'per_page' => $comments_per_page,
//              'avatar_size'   => 16,
        ), $comments);

Did I miss something or is it a bug or Codex needs to be updated?

Related posts

1 comment

  1. The default for reverse_top_level is null. Now let’s take a look at the function source:

    if ( null === $r['reverse_top_level'] )
        $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
    

    As you can see, it takes the value from the comment_order option. And that is either desc or asc. If the value is desc, then it will be set to true. Now Walker_Comment, which extends Walker, retrieves the parsed arguments $r as last argument for paged_walk(). And that method is a method of the Walker class. Let’s look at its source. And there we can see the following:

    if ( ! empty( $args[0]['reverse_top_level'] ) )
        $elements = array_reverse( $elements );
        // does other stuff here
    

    As empty evaluates false equal to null or ! isset, this part won’t trigger. That’s it.

Comments are closed.