wp_list_comments renders incorrectly nested <ul>

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:

Read More

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?

Related posts

Leave a Reply