1

comments.php

 <?php 
       $args=array(
         'type'=> 'comment',
         'callback'=>'my_comment_list',
        );
    ?>
    <ol class="comments-list">
     <?php wp_list_comments($args) ?>
    </ol>

function.php

function my_comment_list($comment,$arg,$depth){

}

When trying to create a callback function called my_comment_list, it looks like I need three types of arguments for the callback function, $ comment, $ arg, $ depth,

My question is:

How do you know you need these arguments for callback function? and Where do you get detailed explanations of arguments, etc.?

I usually refer to the below link in Wordpress template tags and functions, but It was not there...

Wordpress Developer Resource

1 Answer 1

2

wp_list_comments() uses Walker_Comment class to render the output.

See Walker_Comment->start_el() method for callback argument:

https://developer.wordpress.org/reference/classes/walker_comment/start_el/

And Walker_Comment->end_el() method for end-callback argument:

https://developer.wordpress.org/reference/classes/walker_comment/end_el/

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.