Is there an easy way to get the comments of a node programmatically in Drupal 7?
3 Answers
5
votes
1
votes
0
votes
In Drupal 7 you can use the below code to get all the comments of a node using node ID
$nid = 2; // node ID
$comments = db_select('comment')
->fields('comment', array('name','subject'))
->condition('nid', $nid, '=')
->execute()
->fetchAssoc();
foreach($comments as $comment) {
print your comments here
}
In Drupal 6 you can use the comment_render() ;