From past couple of months, I have been trying to make Blogger commenting system look cool 😎 and beautiful. I have also shared different tricks to customize blogger comment system.
Today, I want to reverse the order of comments in blogger as I realized by default blogger displays oldest comments first and newest ones at the bottom.
I had couple of questions:
Let me show you how.
Sorting Blogger comments from New to Old
Blogger provides some lines of code to display comments. If you open your theme HTML code, you can find this piece of code:
<b:loop values='data:post.comments' var='comment'>
<b:loop values='data:post.comments where (c => not c.inReplyTo or c.inReplyTo == 0)' var='comment'>
This line 👆simply loops through each comment for this post. To reverse the order of these comments you'll need a way to indicate you want to loop starting at the most recent comment and work your way through the older comments. But how? There is a way to do it natively in Blogger using reverse HTML tag.
reverse='1' to above code.
Reverse='1' reverses the default order of comments in blogger and displays latest to oldest.
<b:loop reverse='1' values='data:post.comments' var='comment'>
<b:loop reverse='1' values='data:post.comments where (c => not c.inReplyTo or c.inReplyTo == 0)' var='comment'>
That is all. Now your comments are sorted from new to old. Happy Blogging! ✊
Any Questions? Leave a comment below. And do you want me to write more guides on customizing blogger commenting system? If yes, let me know.
Some cool articles to check next -