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'
));
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?
The default for
reverse_top_level
isnull
. Now let’s take a look at the function source:As you can see, it takes the value from the
comment_order
option. And that is eitherdesc
orasc
. If the value isdesc
, then it will be set totrue
. NowWalker_Comment
, whichextends Walker
, retrieves the parsed arguments$r
as last argument forpaged_walk()
. And that method is a method of theWalker
class. Let’s look at its source. And there we can see the following:As
empty
evaluatesfalse
equal tonull
or! isset
, this part won’t trigger. That’s it.