Forums

Comments in reverse order (9 posts)

  1. minute44
    Member
    Posted 1 year ago #

    At the moment my comments all display most recent at the bottom...

    How do I reverse that?

  2. deuced
    Member
    Posted 1 year ago #

  3. trig338
    Member
    Posted 1 year ago #

    I've searched the sama answer for many hours.

    My theme (simplicity) has a comments.php with this line:

    $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = '$id' AND comment_approved = '1' ORDER BY comment_date");`

    Can I add asc_order or something?

  4. deuced
    Member
    Posted 1 year ago #

    following this tip find comments.php in your theme and

    replace this:
    <?php foreach ($comments as $comment) : ?>

    with that:
    <?php foreach (array_reverse($comments) as $comment) : ?>

    then whatever order you have will be reversed.

  5. trig338
    Member
    Posted 1 year ago #

    Thanks! That fixed it. Next I will try to move the comments form as well:)

  6. U-recca
    Member
    Posted 1 year ago #

    where do you put this code??

    Thanks in advance

  7. peacearena
    Member
    Posted 1 year ago #

    Caveat: The comments will be in reverse order, but the last (top) comment will be numbered as "1.". One solution is to set the list-style-type to "none" so that there just aren't numbers at all. I'd prefer to show the highest number instead, but have no idea if this is possible, or how to do it if it is.

  8. schikowski
    Member
    Posted 10 months ago #

    deuced, just what I was looking for.
    Thanks!!!

  9. rogerraphael
    Member
    Posted 5 months ago #

    I wanted my comments to display newest-first, with reverse numbering: 10, 9, 8, etc. My workaround for this was to change the ol for the comments to an ul, and then add a counter that decrements with each trip around the loop that generates the comments. Not sure that's the most elegant way to do it, but it worked.

Topic Closed

This topic has been closed to new replies.

About this Topic