Codex

Function Reference/get approved comments

Contents

Description

Takes post ID and returns an array of objects that represent comments that have been submitted and approved.

Usage

<?php
  $comment_array = get_approved_comments($post_id); 
?>

Example

In this example we will output a simple list of comment IDs and corresponding post IDs.

<?php
   $postID = 1;
   $comment_array = get_approved_comments(1);

   foreach($comment_array as $comment){
      echo $comment->comment_ID." => ".$comment->comment_post_ID."\n";
   }
?>

Parameters

$post_id
(integer) (required) The ID of the post to retrieve comments from.
Default: None

This article is marked as in need of editing. You can help Codex by editing it.