We could rewrite:
wp_list_comments( array(
'callback' => 'bootstrap_comment_callback',
));
with the null walker
parameter:
wp_list_comments( array(
'walker' => null,
'callback' => 'bootstrap_comment_callback',
));
which means we are using the default Walker_Comment
class:
wp_list_comments( array(
'walker' => new Walker_Comment,
'callback' => 'bootstrap_comment_callback',
));
The Walker_Comment::start_el()
method is just a wrapper for one of these protected methods:
Walker_Comment::comment()
Walker_Comment::html5_comment()
Walker_Comment::ping()
that, depending on the context, append each comment to the output string when walking along the comment tree.
Using a custom walker class, that extends the Walker_Comment
class, gives us the ability to override these public methods:
Walker_Comment::start_el()
Walker_Comment::end_el()
Walker_Comment::start_lvl()
Walker_Comment::end_lvl()
Walker_Comment::display_element()
in addition to the protected ones above.
If we only need to modify the output of the start_el()
method, we would only need to use the callback
parameter in wp_list_comments()
.