WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get approved comments

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); 
?>

Parameters

$post_id
(integer) (required) The ID of the post
Default: None

Return Values

$comments (array) 
The approved comments

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($postID);

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

Notes

Change Log

Since: 2.0.0

Source File

current_user_can_for_blog() is located in wp-includes/capabilities.php

Related

 

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.