admin管理员组文章数量:1415120
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.
本文标签: oopHow pass args to wplistcomments callback
版权声明:本文标题:oop - How pass args to wp_list_comments callback? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745197978a2647231.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论