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


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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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