Passing arguments to wp_list_comments callback function

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;

Leave a Comment