wp_list_comments()
accepts a walker
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 in wp-includes/comment-template.php
.
To change the complete comment list out, create a custom walker in your functions.php
which extends
the default class:
class WPSE_127257_Walker_Comment extends Walker_Comment
{
function start_lvl( &$output, $depth = 0, $args = array() ) {
// do nothing.
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
// do nothing.
}
function end_el( &$output, $comment, $depth = 0, $args = array() ) {
// do nothing, and no </li> will be created
}
protected function comment( $comment, $depth, $args ) {
// create the comment output
// use the code from your old callback here
}
}
And then you use that class when you call wp_list_comments()
:
wp_list_comments(
array (
'walker' => new WPSE_127257_Walker_Comment
)
);