WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] <?php wp_list_comments(); ?> (5 posts)

  1. richarduk
    Member
    Posted 5 years ago #

    Is it possible to style <?php wp_list_comments(); ?> in comments.php?

    In the old comments loop it was possible to do more or less anything. For example adding numbers besides comments, adding different css styles to odd comments.

    In the new comments loop it looks like <?php wp_list_comments(); ?> outputs everything. Almost as if <?php wp_list_comments(); ?> is the loop itself

    < ?php if ( have_comments() ) : ?>
    
    <ul class="commentlist">
    < ?php wp_list_comments(); ?>
    </ul>
    
    < ?php else: ?>

    Have I misunderstood this?

    Editted: just found all the classes that are automatically added
    http://ottodestruct.com/blog/2008/09/29/wordpress-27-comments-enhancements/#more-424

    But I still feel that I've lost some of the control I had before

  2. adamh
    Member
    Posted 5 years ago #

    I've just had to do this myself - on the codex there's a page about the tag which explains how to provide a callback function which overrides the outputted html.

    http://codex.wordpress.org/Template_Tags/wp_list_comments

    See the section 'Comments Only With A Custom Comment Display'

  3. richarduk
    Member
    Posted 5 years ago #

    Ah, I see.

    Blimey, that looks complicated.

    Is it worth losing simplicity for threaded comments? And paginated pages too, I think?

    I wonder if there's some simple code somewhere that would make the old comments loop do the same job?

  4. adamh
    Member
    Posted 5 years ago #

    Yeah, I thought it looked complicated but the only complex thing is the mixing of php and html - I prefer to output all my html from php without breaking out. Once I got past this mental block, it's not that bad!

  5. richarduk
    Member
    Posted 5 years ago #

    Actually, Otto's comments (from the link above) demonstrate how it looks and it's not so bad.

    By Viewing Source I can get a good idea of all the different classes, too. As you say Adamh there's a mental block to get over. I think I'll sleep on it :-)

Topic Closed

This topic has been closed to new replies.

About this Topic