wp_list_comments()
没有过滤器或挂钩,所以会有点困难,您可以使用comments_array
过滤器挂钩
add_filter(\'comments_array\',\'my_custom_comments_list\');
function my_custom_comments_list($comments, $post_id){
//if criteria are met
//pull your comments from your own table
//in to an array and return it.
return $my_comments;
//else return $comments
}
至于“拦截评论提交并处理”芯片,答案将是使用
preprocess_comment
过滤器挂钩,但您希望能够避免WordPress表单将注释插入到默认表中,因此您可以使用
wp_insert_comment
插入注释后立即从默认表中删除注释的操作挂钩:
add_action(\'wp_insert_comment\',\'remove_comment_from_default_table\');
function remove_comment_from_default_table( $id, $comment){
//if criteria are met
//and the comment was inserted in your own table
//remove it from the default table:
wp_delete_comment($id, $force_delete = true);
}