Fix for wordpress comments order
Using this snippet you can fix the order of wordpress comments.
In my latest project I have used the wordpress comments system to create a testimonials page for an apartment site, but I have seen that the default settings of wordpress gave me a wrong results.
In wordpress you can change the ordering of your comments from older to newer, but the problem is when you decide to paginate these comments. You can set the first or the last page of comments to display by default, but if you have 8 comments and you want 5 per page, you have that the last one has the newest 3 comments with the first one with the oldest 5 comments. The usability is very bad, so I have decided to re-set the default settings of wp and create a filter to resort the order of them.
Open the functions.php file that you can find into your template folder, if you haven’t it you have to create it. After this, add this code at the bottom of file:
if (!function_exists('theme_reverse_comments')) {
function theme_reverse_comments($comments) {
return array_reverse($comments);
}
}
add_filter ('comments_array', 'theme_reverse_comments');
It’s very simple
Enjoy!
Chris Charlwood February 14, 2013 22:17:43
Thanks for this snippet – I am using this for an activity feed stream for a WordPress intranet. Works like a charm!