在典型的WordPress主题中,您可以使用wp_list_comments()函数输出帖子/页面的注释的完整列表。 通过自定义为该注释列表生成HTML标记的方式,此功能提供的功能不多。 要为注释列表编写自己的标记,可以在wp_list_comments()中使用回调函数作为参数,因此它也非常抽象。
在functions.php中
<?php
function my_custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<?php endif; ?>
// Comments markup code here, e.g. functions like comment_text();
}
?>
在comments.php中
<?php
wp_list_comments("callback=my_custom_comments");
?>
翻译自: https://css-tricks.com/snippets/wordpress/customize-comments-markup/