0

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.org/Function_Reference/wp_list_comments

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.