2

Hi all and happy holidays!

I have a page on which I enabled threaded commenting. At present, the comments are ordered new to old by when the thread started:

-Comment 3
-Comment 2
  -Comment 5
-Comment 1
  -Comment 4

Actually, I want the last active thread to be the first, in such a way that the listing would resemble:

-Comment 2
  -Comment 5
-Comment 1
  -Comment 4
-Comment 3

How could this be achieved?

2 Answers 2

0

Simply go to Settings > Discussion > Other comment settings > then look for the pull-down menu that will let you reverse the order.

As per this video:

https://premium.wpmudev.org/blog/wp-content/uploads/2014/01/New-comments-first.webm

1
  • 1
    I have that setting, and it results in the discussion ordered as described in my first code block. They are ordered reversely by thread starter, not by latest comment.
    – jberculo
    Commented Dec 28, 2020 at 14:03
0

Simply add this code in your theme’s functions.php file.

function wpb_reverse_comments($comments) 
 {
    return array_reverse($comments);
}   
add_filter('comments_array','wpb_reverse_comments');

This code uses the comments_array filter to reverse the display of comments on your WordPress site.

2
  • This basically does the same as setting the option in the backend.
    – jberculo
    Commented Dec 31, 2020 at 11:46
  • You want to add option in admin panel
    – HK89
    Commented Jan 1, 2021 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.