How to programmatically print all comments from a given node? I need to print comments belonging to a given node. So basically, get a node id then choose all the comments from a given node and print them. I know that I can print one comment (for example with id=12) using the following code:

&lt;?php
$comment = _comment_load(12);
return theme('comment',$comment);
?&gt;


Can anyone tell me how to do this?
If you are looking for a ready to use function, take a look at comment_render().

Example use (say the node you want comments for has nid = 5):

&lt;?php
  $node = node_load(5);
 print comment_render($node);
?&gt;


Or else you can manually query the database (comments table) to get all comments that have a matching nid.

&lt;?php
  $nid = 5;
  db_query('SELECT * FROM {comments} WHERE nid = %d', $nid);
?&gt;