WordPress.org

Support

Support » Themes and Templates » Reverse comments order?

Reverse comments order?

  • starcrash13

    @starcrash13

    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

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi

    @esmi

    Forum Moderator

    What options did you choose in Settings/Discussion?

    starcrash13

    @starcrash13

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

    esmi

    @esmi

    Forum Moderator

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

    starcrash13

    @starcrash13

    I’ve tried both “first” and “last”.

    esmi

    @esmi

    Forum Moderator

    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.

    starcrash13

    @starcrash13

    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” ‘ : ”;
    ?>

    esmi

    @esmi

    Forum Moderator

    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.

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

    with

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

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Reverse comments order?’ is closed to new replies.