最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

comments - Callback function argument which is required for wp_list_comments ()

programmeradmin2浏览0评论

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

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

Share Improve this question asked Apr 11, 2020 at 6:24 Kazu25Kazu25 331 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

wp_list_comments() uses Walker_Comment class to render the output.

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

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

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

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

发布评论

评论列表(0)

  1. 暂无评论