One can customize single comment markup using the callback argument in wp_list_comments like this:

$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment' );
wp_list_comments( $args );

The question is, how to pass arguments to that my_callback function? Already it gets three:

function my_callback( $comment, $args, $depth )

But I need to add my own 4th argument

2 Answers 2


Finally I figured it out. you may simply add your arguments to the wp_list_comments as associative key => value pairs like this:

$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment', 'arg1' => $arg1 );
wp_list_comments( $args );

and then in your my_callback you have:

function my_callback( $comment, $args, $depth )

where you have access to $arg1;


You may use the use in function:

function my_callback( $comment, $args, $depth ) use ( $my_arg1, $my_arg2, ... )
  • That doesn't work for named functions.
    – fuxia
    Commented Mar 19, 2022 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.