More than 800+ satisfied clients and counting, since 2010

Blog

How to Rearrange Comments in WordPress – Display the Most Recent One on Top

Rearranging comments so as to display the latest one on the top is becoming a totally new trend that more and more bloggers are implementing this on their site. If your blog has got a lot of user interaction their, then this option will be your choice because commonly the recent comments get hided on the last pages or at the  bottom. In this article I will show you how to rearrange comments in WordPress and display the most latest one on the top.

There are multiple ways that have been available online and some even require us to edit our core files. Editing core files is not a good option because every time we upgrade WordPress, we have to make that change again. We have got two ways that we can use to rearrange the comments and display them in their descending order showing the most latest comment first that will not require us to change the core files at all.

Method 1:

This method requires us to add a very simple code to our comments.php. First we need to find this line:

foreach ($comments as $comment) {

Note: These may vary slightly in the different themes.  Now immediately before this line we need to add:

add

$comments = array_reverse($comments);

With this reverse function, we can rearrange our comments and show them in their descending order.

Method 2:

The second method makes this job even more easier for those who are not comfortable with codes. This is a plugin called as  Simple Reverse Comments. With the help of this  plugin, we do not have to edit any of our template files at all. Simply just  download this plugin and activate it.

Method 3:

A most common problem with the WordPress sites is that we can’t easily rearrange comments order. Sure, we can use a custom menu, but also for some sites we have to rearrange the order of our comments. This code will show  how to do it more easily.

This code above will find for a specific category (Don’t forget to get update line 5) and then do replace it on the top of all the other categories. This code has to be pasted

<?php
$categories = get_terms('books_category');
for( $i=0; $i<sizeof($categories); $i++ ){
 if ( $categories[$i]->name == 'New Publications' ) :
$latest = array($categories[$i]);
unset($categories[$i]);
endif;
}
if( isset($latest) )
array_splice( $categories, 0, 0, $latest );
?>

Ever since I started using WordPress 3+ themes and then using the custom post types for the things such as the portfolios, services, faqs, staff, or sliders..etc, I’ve been then getting a lot of more questions from many people asking me that how they can rearrange the order of their comments . Unfortunately it’s not a very obvious how to do this in a WordPress and there isn’t many  very easy and manageable way.

In this following post I’ve shown to you how you can change the order of your custom comments using this  different methods: changing the post date of our custom comments or using some nice awesome free a WordPress plugin called as “Post Type Order”.

Written by

The author didnt add any Information to his profile yet