wp_list_comments() will append an end tag to your comment

July 29, 2010

On every call to your call back from wp_list_comments(), there will be an end tag appended, this tag can be either </li> or </div> depending on your style parameter. Therefore, in your call back function, don't put your own end tag there. For example, my call back function was like this:

function custom_comments($comment, $args, $depth) {
  ?>
  <li id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
  ...
  </li>
  <?php
}

Perfectly fine, except that there will be another </li> appears when the page shows, making html errors and potentially may break your page's layout. The obvious solution is to remove the </li> tag in my function.

Leave a comment