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 user145078user1450781 Answer
Reset to default 0After 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
评论列表(0条)