Reversing the order of your comments
We develop our client’s sites in WordPress since it is such a flexible and powerful system. It allows our clients to update and maintain their own site content which is always a good thing. Sometimes editing the defaults in the system is very easy, but other times it takes a little finagling.
Recently a client wanted to reverse the order of the comments in their blog. By default, WordPress lists comments from oldest to newest. Now, there is a setting under “Discussions” within the WordPress panel to select comments to display in the reverse order: newest to oldest. When we adjusted this setting within the client’s WordPress admin panel though, nothing changed. It seemed we had stumbled across a bug of some sort. Thankfully though, there is an easy fix:
1. Open up the comments.php template
2. Locate this line:
<?php foreach ($comments as $comment) : ?>
3. Replace it with the following:
<?php foreach (array_reverse($comments) as $comment) : ?>
That’s it. Comments will now display newest to oldest.
December 9th, 2010 at 4:05 pm
Hi,
I design and build websites using WordPress too, and this tip is absolutely brilliant!
Cheers!
S.