Most blogs displays comments from the older to the younger. I have seen many bloggers who asked how to reverse the comment list order, so here’s a recipe.
That’s super easy: We only need the array_reverse() php function.
Most blogs displays comments from the older to the younger. I have seen many bloggers who asked how to reverse the comment list order, so here’s a recipe.
That’s super easy: We only need the array_reverse() php function.
For those who knows at least a bit of the php programming language, you probably already heard about the array_reverse() function. This function takes an array as argument, and return it reversed.
Just open the comments.php file from your theme. Find the following line:
<?php foreach ($comments as $comment) : ?>
Now, add this line below:
<?php $comments = array_reverse($comments, true); ?>
The code should look like this:
<?php $comments = array_reverse($comments, true); ?> <?php foreach ($comments as $comment) : ?> // comments loop <?php endforeach; ?>
That's all. Comments are now displayed in reverse order.
11 Responses
I did it! Thanks!
Very nice little trick!
Brilliant. So simple but it does the job. Thanks.
Thanks for this quick solution
Definitively it works
all the software shoud be like this, easy and simple…
thx
Million thanks! Very helpfull!
Trackbacks: