oop - How pass args to wp_list_comments callback?

i need to pass an arg to function that i am specifying as callback for wp_list_commentspublic function ggowl_comment_lis

i need to pass an arg to function that i am specifying as callback for wp_list_comments

public function ggowl_comment_lister($ggowl_id,$icon_html){
        $args = array (
         'post_type' => 'product',
         'post_id' => $ggowl_id
        );
        $comments = get_comments( $args );
        $args = array(
          'callback' => array($this, 'ggowl_woocommerce_comments'),
        );
        wp_list_comments( $args , $comments);
      }

but public function ggowl_woocommerce_comments($ggowl_id){ this does not work as $ggowl_id is not defined

i need to pass an arg to function that i am specifying as callback for wp_list_comments

public function ggowl_comment_lister($ggowl_id,$icon_html){
        $args = array (
         'post_type' => 'product',
         'post_id' => $ggowl_id
        );
        $comments = get_comments( $args );
        $args = array(
          'callback' => array($this, 'ggowl_woocommerce_comments'),
        );
        wp_list_comments( $args , $comments);
      }

but public function ggowl_woocommerce_comments($ggowl_id){ this does not work as $ggowl_id is not defined

https://codex.wordpress/Function_Reference/wp_list_comments

Share Improve this question asked Aug 30, 2019 at 20:33 user145078user145078
Add a comment  | 

1 Answer 1

Reset to default 0

After looking at the wp_list_comments() and Walker_Comment sources I would assume the callback is what the Walker uses to render single comments. And the callback recieves three parameters $comment, $args, $depth when the Walker calls it.

Based on this, I assume you should be able to just push custom key-value pairs to your $args array and then have them available when the callback function is called.

This is slighty unfamiliar territory for me, so I may be mistaken.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745197978a4616184.html

相关推荐

  • oop - How pass args to wp_list_comments callback?

    i need to pass an arg to function that i am specifying as callback for wp_list_commentspublic function ggowl_comment_lis

    13小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信