wp_list_comments显示评论列表

在comments.php模板中使用,以列出特定帖子的评论

wp_list_comments( string|array $args = array(), WP_Comment[] $comments = null )

$args

参数说明类型可选值默认值
walker输出评论的Walker类的实例objectnull
max_depth最大深度int''
style列表排序的样式string'ul'、'ol'、'div''ul'
callback要使用的回调函数callablenull
end-callback最后使用的回调函数callablenull
type要输出的评论的类型string 'all', 'comment', 'pingback', 'trackback', 'pings''all'
page列出评论的页面IDint''
per_page每页列出的评论数int''
avatar_size头像大小的高度和宽度尺寸int32
reverse_top_level列出的注释的顺序。如果为true,则将首先显示最新评论bool''
reverse_children是否反转列表中的子注释bool''
format如何格式化评论列表。如果主题支持,则默认为“ html5”string'html5', 'xhtml'text
short_ping是否输出短pingboolfalse
echo是回显输出还是返回输出booltrue
$defaults = array(
	'walker'            => null,
	'max_depth'         => '',
	'style'             => 'ul',
	'callback'          => null,
	'end-callback'      => null,
	'type'              => 'all',
	'page'              => '',
	'per_page'          => '',
	'avatar_size'       => 32,
	'reverse_top_level' => null,
	'reverse_children'  => '',
	'format'            => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
	'short_ping'        => false,
	'echo'              => true,
);
$args = array(
	'walker' => new my_comment_walker()
);
wp_list_comments(array_merge($defaults, $args));

class my_comment_walker extends Walker {
	/*...code...*/
}
评论
:broken_heart: :confounded: :flushed: :frowning: :grinning: :heart: :kissing_heart: :mask: :pensive: :rage: :relaxed: :scream: :smile: :smirk: :sob: :stuck_out_tongue_closed_eyes: :stuck_out_tongue_winking_eye: :wink: