Resources     Blog  

  1. Home
  2. WordPress Tutorials
  3. How to Show the Most Recent Comments in WordPress

How to Show the Most Recent Comments in WordPress

Do you want to display the most recent comment in your comments section? If you do not change the order your comments are displayed, your newest comments will be out of sight at the bottom of the page. This can make it very difficult for visitors to communicate with each other in the comments section.

This is a serious problem since the comments section is a place designed for visitors to communicate with each other and leave valuable feedback on your content. Thankfully, WordPress is fully customizable, so it’s quite easy to change this. Today, I will demonstrate how to show the most recent comments at the top in WordPress with two methods.

Why Show the Most Recent Comments

If you have a very active comments section, newer comments can easily get buried at the bottom. This is not good for the community because only the first couple of comments will get seen. This may discourage some visitors from bothering to leave comments. Think about the last time you decided to scroll to the bottom of a comments section. It’s probably hard to remember that since it is not a common thing to do.

Thus, moving the most recent comments to the top so they can be seen is a simple and logical choice. Not only will it help visitors communicate with each other, but it will make the comments section seem more lively. This is because the comments at the top will be changing frequently instead of being the exact same every time. This is especially helpful if some of your first comments say “First!”, which still happens a lot.

How to Show the Most Recent Comments in WordPress

Today, I will demonstrate how to show the most recent comments at the top in WordPress with two methods. The first method involves using the built-in comments section settings. There is a setting that allows you to rearrange comments from newest to oldest. If for some reason, you do not want to use the first method, you can accomplish this by adding a few lines of code to your theme’s functions.php file. In either case, you will be able to display the most recent comments at the top.

Method 1: Discussion Settings

The discussion settings allow you to tweak the various settings of your comments section. They also allow you to assign Gravatars and Author profile images.

On the left-hand admin panel, click on Settings and select the Discussion option.

Click on Settings and select the Discussion option.

Locate the Other comment settings section. The last setting in this section will decide the display order for your comments. By default, it should display Older. Change it from Older to Newer.

Change it from Older to Newer.

Scroll down to the bottom of the page and click on the “Save Changes” button.

Click on the "Save Changes" button.

Congratulations, you have successfully rearranged your WordPress comments to display the most recent comments at the top. You can change this back at any time by repeating the steps and changing it from newer to older.

Method 2: Code Approach

If you do not want to use the first method, don’t worry, another alternative is to do a bit of coding. It is very simple and will only require you to copy and paste a few lines of code. Since you will be editing files on the backend of your website, it is a good idea to create a backup of your website. This will ensure that if a mistake is made, you can revert your website to before the mistake was made.

Let’s start by logging into the cPanel and clicking on the File Manager option. The File Manager will allow you to access all of the files related to your website.

Click on the File Manager option.

You need to locate your theme’s functions.php file. Click on the public_html directory, then click on the wp-content folder. Inside of this folder, you will find all of the content related to your website. Click on the themes folder and enter the folder of the theme you are currently using. Finally, right-click on the functions.php file and select the Edit option.

Select the "Edit" option.

A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. This will ensure that you can revert your website back to when it was working if something goes wrong. Click on the “Edit” button. A new tab will open containing all of the code from the file.

Click on the "Edit" button.

Copy and paste the following lines of code into your theme’s functions.php file:

function swap_comment_order($comments) {
return array_reverse($comments);
}
add_filter (‘comments_array’, ‘swap_comment_order’);

Once you have inserted the code into the functions.php file, click on the “Save Changes” button to finish.

Click on the "Save Changes" button.

This will have the same effect as the last method and display the newest comments at the top of the page.

Interact With Your Visitors

The comments section allows visitors to communicate with each other, but it also allows you to interact with visitors. This is very important because regularly interacting with your visitors will help build a strong relationship. Keep in mind there are many ways to interact with your visitors. This may be through an email subscription or more commonly on social media platforms.

Social media platforms are the best way to interact with your visitors. There are multiple platforms and they generate billions of views every month. This is not just a good choice for interactions, but marketing on these platforms is essential in today’s world. Almost every single major business corporation has a significant social media presence, so don’t be afraid to join them.

Do you think showing the newest comments should be the default option? Which method have you used?

Author: Ron Helms

I currently work for GreenGeeks as a Support Technician. My primary roles are supporting our VPS and Dedicated server clients, as well as performing site migrations. With experience in the web hosting industry since 2009, there is rarely a question I can’t help answer. In my spare time, I enjoy gaming and working on cars as an automotive enthusiast.

Was this article helpful?

Related Articles

Leave a Comment

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