Reverse WordPress comments order

October 19, 2008 · Print This Article

For those who knows at least a bit of the php programming language, you probably already heard about the array_reverse() function. This function takes an array as argument, and return it reversed.

Just open the comments.php file from your theme. Find the following line:
<?php foreach ($comments as $comment) : ?>
Now, add this line below:
<?php $comments = array_reverse($comments, true); ?>
The code should look like this:
<?php $comments = array_reverse($comments, true); ?>
<?php foreach ($comments as $comment) : ?>
// comments loop
<?php endforeach; ?>

That’s all. Comments are now displayed in reverse order.


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.