Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to figure out how wp_list_comments works. So I made the simplest possible callback just to see the structure of the result:

function custom_comments_callback( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment;

    ?>
    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
        Hello!
    </li>
    <?php
    }

I thought this function would be structurally correct but the result seems to contain incorrectly nested <ul> elements:

enter image description here

I thought an <ul> in an <ul> always had to be enclosed in a <li> as explained here for instance. Should I modify my callback function or am I missing something else here?

share|improve this question
4  
Your callback should not include a closing </li> tag, the comment walker adds these as and when necessary. –  t31os Apr 20 '13 at 7:57
1  
@t31os: thanks, good catch! Completely overlooked that. Problem solved. –  RubenGeert Apr 20 '13 at 9:01
    
Happy to help. :) –  t31os Apr 20 '13 at 10:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.