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.

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'

            '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?


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.

  • I am sorry. I did not understand. My point is that Codex explains that the value true gives us the most recent comment first. I am getting the oldest first if I use the value true. The null part is just that I would expect the most recent to be displayed too. But my question is more about the true giving me the oldest comments first. – Radek Oct 19 '13 at 6:17
  • Radek, have you checked the "comment order" in your admin UI settings? – kaiser Oct 19 '13 at 11:29
  • I thought the custom code got higher priority ... – Radek Nov 16 '13 at 9:19
  • @Radek There is no priority, because the "custom code" doesn't get executed/used. Please read my explanation again - carefully. Then you'll see why your argument gets ignored by core. – kaiser Nov 16 '13 at 12:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.