Forums

Display comments in reverse order on PAGES only (4 posts)

  1. pad
    Member
    Posted 2 years ago #

    I have comments on posts and pages, I'd like the post's comments to display from oldest to newest, but on pages to display from newest to oldest.

    Is this possible and if so, how?

  2. pad
    Member
    Posted 2 years ago #

    Anyone?

  3. Mark / t31os
    Moderator
    Posted 2 years ago #

    What code are you currently using to display comments?

  4. Mark / t31os
    Moderator
    Posted 2 years ago #

    Assuming your theme, like any other, uses wp_list_comments() inside comments.php, then just add the following parameter.

    reverse_top_level

    ..setting the value to either 0 or 1, depending on which order you want..

    Info on function:
    http://codex.wordpress.org/Template_Tags/wp_list_comments

    NOTE: The above parameter isn't documented, but does work (tested it).

    Look at using a conditional tag in the comments file along with the new parameter.

    Info on conditions:
    http://codex.wordpress.org/Conditional_Tags

    Let's assume you have something like this..

    <ol class="commentlist">
    			<?php wp_list_comments(); ?>
    		</ol>

    Update that with, something along the lines of..

    <ol class="commentlist">
    			<?php if(is_page()) : wp_list_comments('reverse_top_level=1'); else : wp_list_comments();  endif; ?>
    		</ol>

    See how far that gets you.. ;)

Topic Closed

This topic has been closed to new replies.

About this Topic