参数
- $post_id
- 
(int) (必填) 文章的 ID 
- $args
- 
(array) (可选) 有关可接受参数的信息,请参阅WP_Comment_Query::__construct()。 默认值: array() 
返回
(WP_Comment[]|int[]|int) 批准的评论,或者如果$count参数为true,返回评论的数量。
源码
更新日志
| 版本 | 描述 | 
|---|---|
| 4.1.0 | 重构利用WP_Comment_Query而非直接查询 | 
| 2.0.0 | 开始引入 | 
使用示例
- 示例 - 在本例中,我们将输出一个简单的评论ID列表和相应的文章ID。 - <?php $postID = 1; $comment_array = get_approved_comments($postID); foreach($comment_array as $comment){ echo $comment->comment_ID." => ".$comment->comment_post_ID."\n"; } ?>
