Sort comment in reverse order – WordPress

In many cases the blogger may want to sort the comment of there WordPress blog by latest comment at top, like me.

Instead of installing any plugin, i have done following code changes in “comments.php“.

Somewhere in “comments.php“, you will find below line of code –

foreach ($comments as $comment) :

Add following code just above the for loop

$comments = array_reverse($comments);

so, the final code will become

	/*Start By Jitendra*/
	$comments = array_reverse($comments);
	/*End By Jitendra*/
	foreach ($comments as $comment) :

I hope, this little trick will be very useful for few WordPress bloggers.







Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.