How to Make Your Comments Appear in ‘Newest First’ Order in WordPress

The Internet Patrol - Patrolling the Internet for You

When readers leave comments on most sites running WordPress, the newest comment goes to the bottom of the queue, with the oldest comment at the top. But many site admins prefer to have comments appear in ‘reverse order’, having the newest comments appear first, at the top, and then go in descending order from newest to oldest. There are some plugins out there which will allow you to reverse the order of how comments appear on your blog or website, but why add another plugin to the mix when it is so easy to make comments appear newest first? Here’s how.

In the directory for the WordPress theme you are using, you will find a file called ‘comments.php’.


how-to-newest-comments-first-wordpress

Make a backup copy of that file (always make a backup before editing source files).

Now, using your favourite editor, edit the comments.php file.

No Paywall Here!
The Internet Patrol is and always has been free. We don't hide our articles behind a paywall, or restrict the number of articles you can read in a month if you don't give us money. That said, it does cost us money to run the site, so if something you read here was helpful or useful, won't you consider donating something to help keep the Internet Patrol free?
Click for amount options
Other Amount:
What info did you find here today?:

 

Right around line 14 or so of comments.php, you will see this line:

<?php foreach ($comments as $comment); ?>

Replace that line with this line:

 

<?php foreach (array_reverse($comments) as $comment); ?>

Then save the file, and almost as if by magic, the comments on your WordPress site will be displayed in “newest at the top” order.

No Paywall Here!
The Internet Patrol is and always has been free. We don't hide our articles behind a paywall, or restrict the number of articles you can read in a month if you don't give us money. That said, it does cost us money to run the site, so if something you read here was helpful or useful, won't you consider donating something to help keep the Internet Patrol free?
Click for amount options
Other Amount:
What info did you find here today?:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.