How to Reverse WordPress Comment Order to Show the Latest on Top

Here’s a handy little hack that I found over at iwebsource.net. It basically reverses your comment order to show the latest ones on top, so that you don’t have to scroll all the way to the bottom to find read the most recent comments.

Add this to your theme’s functions.php file:

1
2
3
4
5
6
if (!function_exists('iweb_reverse_comments')) {
    function iweb_reverse_comments($comments) {
        return array_reverse($comments);
    }   
}
add_filter ('comments_array', 'iweb_reverse_comments');

I tested this hack on the WordPress 3.1 and it works as advertised. It’s very useful if you have posts that get pages and pages worth of comments.