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(); ?>">

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?

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.