Whether your theme shows the newest comments on top or the oldest, you may want to change the order of comments in WordPress. Seeing the latest comments on top can also help users engage more with your content. No matter what order you (or your visitors) prefer, here are two simple ways to rearrange WordPress comments.
First I’ll show you how to reorder your comments using the built-in WordPress option:
Using WordPress Comment Order Option
The easiest way to change the order of WordPress comments is using the built-in WordPress option.
There is a built-in option located in Settings>Discussion that will allow you to reverse the order of your WordPress comments.
You’ll see “comments should be displayed with the newer comments at the top of each page” at the bottom of the other comment settings section.
This method may not work with all themes since they could be using custom methods to display comments.
Change WordPress Comment Order using Functions.php Code Snippet
If you’re a more advanced user you can use this code snippet in your functions.php file or using the Code Snippets plugin to reverse comment order:
<?php | |
//Reverse comment order | |
function smartwp_reverse_comment_order( $comments ) { | |
return array_reverse( $comments ); | |
} | |
add_filter ('comments_array', 'smartwp_reverse_comment_order'); |
This code snippet will reverse the order of your WordPress comments. This is helpful if the default WordPress option doesn’t work with your theme.
If you are new to adding code snippets to your site you can watch this video that shows two methods to add them to your site.
I hope this quick WordPress tip was helpful! If you have any issues let me know in the comments below!
One Response
very interesting article for me. it will help me alot.
thanks andy feliciotti