WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display comments from newest to oldest based on timestamp (3 posts)

  1. curtisservices
    Member
    Posted 6 years ago #

    Hello,
    I'm trying to get the comments to display from newest to oldest based on the timestamp. I didn't see an option for this, so I assume it's something I need to tweak in the php code. Any help would be great!

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Add this to your theme's functions.php file:

    function reverse_comments($comments,$id) {
    $comments = array_reverse($comments);
    return $comments;
    }
    add_filter('comments_array','reverse_comments',10,2);
  3. curtisservices
    Member
    Posted 6 years ago #

    It works! You're AWESOME! Thanks for the fast response!

Topic Closed

This topic has been closed to new replies.

About this Topic