I try to get all comments of a specific post, but it is not working like the way I do want. I use $assignment->ID
to get all comments for a specific page ID. Even when I change $assignment->ID
to 101
it is not working and he still shows all the comments of all posts.
foreach($assignments as $assignment) {
echo $assignment->post_title;
$args = array(
'number' => 0,
'status' => 'approve',
// shows all comments, but it shouldn't
'comment_post_ID' => $assignment->ID
);
$comments = get_comments( $args );
if ( $comments ) {
foreach ( $comments as $comment ) {
echo '<li>';
echo $comment->comment_content;
echo '</li>';
}
}
}
I think I miss an important $arg
, but I'm not sure which one. It doesn't matter what I do, all comments are showing up everytime..