Drupal get comments of node

Drupal get comments of node

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, '=')
    foreach($comments as $comment) {
        print your comments here

In Drupal 6 you can use the comment_render() ;



Leave a Reply

Your email address will not be published. Required fields are marked *