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

The Internet Patrol default featured image
Share the knowledge

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.

The Internet Patrol is completely free, and reader-supported. Your tips via CashApp, Venmo, or Paypal are appreciated! Receipts will come from ISIPP.

CashApp us Square Cash app link

Venmo us Venmo link

Paypal us Paypal link

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.

Get New Internet Patrol Articles by Email!

The Internet Patrol is completely free, and reader-supported. Your tips via CashApp, Venmo, or Paypal are appreciated! Receipts will come from ISIPP.

CashApp us Square Cash app link

Venmo us Venmo link

Paypal us Paypal link

 


Share the knowledge

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.