WordPress.org

Ready to get started?Download WordPress

Forums

Reverse comments order? (10 posts)

  1. starcrash13
    Member
    Posted 4 years ago #

    I'm trying to reverse the order of the comments so that the most recent comments are on top. I've tried choosing that in the Discussion Settings on my Dashboard. I've also tried a plugin called Reverse Order Comments. Neither have worked for me. Any ideas?

    Here's my site for reference:
    http://www.anelephantkey.com

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    What options did you choose in Settings/Discussion?

  3. starcrash13
    Member
    Posted 4 years ago #

    "Comments should be displayed with the newer comments at the top of each page."

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    And the previous line in Discussion settings? Which page is being displayed by default?

  5. starcrash13
    Member
    Posted 4 years ago #

    I've tried both "first" and "last".

  6. esmi
    Forum Moderator
    Posted 4 years ago #

    Have a look in your theme's comments.php file for the wp_list_comments() tag. If it's not in there. it would explain why your theme isn't picking up the Discussion settings.

  7. starcrash13
    Member
    Posted 4 years ago #

    Here is what it says. Any suggestions of what I should change or add?

    <!-- start editing here -->

    <?php if ($comments) : ?>
    <h3 id="comments"><?php comments_number(COMMENT_BUTTON_TEXT_ADD_COMMENT, COMMENT_BUTTON_TEXT_ONE_COMMENT, COMMENT_BUTTON_TEXT_MULTIPLE_COMMENT );?></h3>

    <div class="commentlist">

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

    <div <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
    <table width="100%" border="0" cellpadding="2" cellspacing="2">
    <tbody>
    <tr>
    <td width="30%" valign="top"><div align="center"><b><?php comment_author_link() ?></b>

    <?php echo get_avatar( $comment, 32 ); ?></div></td>
    <td width="70%" valign="top"><span style="text-transform: uppercase;"><small><?php comment_date('F jS, Y') ?></small> <small class="commentmetadata"><?php comment_time() ?></small></span> <!--<small><?php edit_comment_link('edit comment','  ',''); ?></small>-->

    <?php if ($comment->comment_approved == '0') : ?>
    <?php echo COMMENT_AWAITING_MODERATION_TEXT; ?>
    <?php endif; ?>

    <?php comment_text() ?></td>
    </tr>
    </tbody>
    </table>
    </div>

    <?php
    /* changes every other comment to a different class */
    $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';
    ?>

  8. esmi
    Forum Moderator
    Posted 4 years ago #

    You could replace everything from <div class="commentlist"> to </div> with <?php wp_list_comments(); ?> but that would almost certainly wreck your current comment display and require a major CSS re-edit.

  9. lawyer01
    Member
    Posted 4 years ago #

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

    with

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

  10. wildwheelz
    Member
    Posted 4 years ago #

    Hey lawyer01 your suggestion above about adding the array_reverse() function did the trick of changing the order that comments are displayed. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic