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



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, privacy policy and cookie policy

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