Wordpress Comments – Show Your Most Recent Comments First
By default, when a new comment is added in Wordpress it is added to the end of the list (i.e. older comments are shown first) – however, many Wordpress users like to be able to do the opposite of this (i.e. display new comments at the top of the list).
This is simple to change and can be achieved simply through one line of code. You initially need to access your comments.php file and locate the following block of code:
<?php foreach ($comments as $comment) : ?> //comment loop <?php endforeach; ?>
Then, above this section, you need to add the following:
<?php $comments = array_reverse($comments, true); ?>
All this line does is reverse the comments array that stores details of your comments thus changing the display of your comments from the default oldest to newest, to newest to oldest.
Once you’ve added this line, your code should look something like the following:
<?php $comments = array_reverse($comments, true); ?> <?php foreach ($comments as $comment) : ?> //comment loop <?php endforeach; ?>
Save your code and then test – your comments should have now been reversed.
















June 9th, 2010 at 10:38 am
thankss you save my day i was dying for this