I’m making a custom comment template, and I do not wish to use a list to display comments.
By default, WordPress puts the following at the end of every comment:
</li><!-- #comment-## -->
I know I could hack the core wp-includes/comment-template.php
, but that would leave me to not be able to update normally. Is there a way to remove this?
Here’s my functions callback:
<section id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment <?php if ($comment->comment_author_email == get_the_author_email()) { echo 'author-comment'; } ?>">
<div class="comment-content">
<aside class="comment-gravatar">
<?php echo get_avatar($comment, '50'); ?>
</aside>
<?php comment_text(); ?>
</div>
<div class="comment-data">
<div class="comment-author">
<p>Posted by : <?php echo get_comment_author(); ?></p>
<p>On <?php the_time('l, F jS, Y') ?> at <?php the_time() ?></p>
</div>
<div class="comment-reply">
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => 'Reply to Comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
</div>
</article>
</section>
wp_list_comments()
accepts awalker
in the array of its first parameter. This is a class that renders the output. If you donât provide one, the default class will be used,Walker_Comment
. You can find it inwp-includes/comment-template.php
.To change the complete comment list out, create a custom walker in your
functions.php
whichextends
the default class:And then you use that class when you call
wp_list_comments()
: