Custom Comment Template
This snippet allows you to use a custom template for displaying comments, giving you more control over their appearance.
PHP
function custom_comment_template($comment, $args, $depth) {
?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<div class="comment-body">
<?php echo get_avatar($comment, 60); ?>
<div class="comment-content">
<h4 class="comment-author"><?php comment_author(); ?></h4>
<div class="comment-metadata">
<time datetime="<?php comment_time('c'); ?>">
<?php printf(__('%1$s at %2$s', 'textdomain'), get_comment_date(), get_comment_time()); ?>
</time>
</div>
<?php comment_text(); ?>
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
</div>
</div>
<?php
}
// Usage in comments.php
wp_list_comments(array(
'callback' => 'custom_comment_template'
));
Snippet Feedback
Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY
5 Views