WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
@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 posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.