cmplieger
cmplieger

Reputation: 7371

Filter wordpress comments by approved

I use this to get wordpress comments for my custom themes:

get_comments( array('status' => 'aprove','order' => 'ASC', 'post_id' => $newpost->ID) );

Everything works besides the fact that comments that are awaiting moderation are not filtered. Following the codex: http://codex.wordpress.org/Function_Reference/get_comment 'status' => 'approve' should filter those out but that doesn't seem to happen.

Didn't I use it the right way?

Upvotes: 0

Views: 2598

Answers (2)

Arifa Sultana
Arifa Sultana

Reputation: 1

It works for me. You can use the following code to show your approved comments in paragraph.

<?php foreach (get_comments(array('status' => 'approve','order' => 'ASC', 'post_id' => $newpost->ID)) as $comment): ?>
<div class="comment-show"><h4><?php echo $comment->comment_author; ?> said: </h4> <p>"<?php echo $comment->comment_content; ?>"</p></div>
<?php endforeach; ?>

i have used in following site to show comments http://rumpa07cse.com/how-to-index-your-website-and-blog-very-quick/

Upvotes: 0

crowjonah
crowjonah

Reputation: 2878

Try approve with two Ps!

get_comments( array('status' => 'approve','order' => 'ASC', 'post_id' => $newpost->ID) );

Here's the docs page for get_comments (you linked to get_comment singular.)

Upvotes: 5

Related Questions