Do you want to change the order of comments in WordPress so the newest ones show up first?
Usually, WordPress displays older comments at the top, but you might prefer to have the most recent comments appear first. This can encourage more interaction and discussions on your site.
In this guide, we will explain how to rearrange comments in WordPress so the newest comments are displayed first.
Why Show the Most Recent Comments First?
Displaying the latest comments at the top can help increase engagement and make your site more dynamic. When the newest comments are shown first, visitors are more likely to join ongoing discussions. This can also make your site look fresh and inviting, potentially increasing the number of page views and lowering the bounce rate.
How to Display the Most Recent Comments First
There are two main methods to show the most recent comments first in WordPress:
- Change Settings in WordPress (No Plugin Needed)
- Manually Set Comment Order with Code
We’ll go through each method step-by-step.
Method 1: Change Settings in WordPress
The easiest way to show the newest comments first is by adjusting your WordPress settings.
- Go to your WordPress dashboard and navigate to Settings » Discussion.
- In the Other comment settings section, find the option that says Comments should be displayed with the older comments at the top of each page.
- Change this setting to newer comments at the top.
- Scroll to the bottom of the page and click Save Changes.
Now, when you visit your blog, you will see the newest comments displayed first.
Method 2: Manually Set Comment Order with Code
If the first method doesn’t work for your custom theme or setup, you can use a bit of code to achieve the same result.
- Install and activate the WPCode plugin to safely add custom code to your WordPress site without editing core files.
- Go to Code Snippets » Add Snippet in your WordPress dashboard.
- Click Add Your Custom Code and choose PHP Snippet from the Code Type dropdown.
- Enter a title for your snippet and then paste the following code into the editor:
php
function wpb_reverse_comments($comments) {
$comment_order = get_option(‘comment_order’);
if ($comment_order == ‘asc’) {
return array_reverse($comments);
}
return $comments;
}
add_filter(‘comments_array’, ‘wpb_reverse_comments’); -