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

<?php
	/*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.

Posted

in

,

by

Tags:


Related Posts

Comments

Leave a Reply

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

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading