How to output comments anywhere within a theme

Feb 11, 2010 · by Tim Kamanin

A little snipped which is among very much needed and asked on forums: "How to output comments in desired place on the page and not on the bottom?". Here is the answer:

if (function_exists('comment_render') && $node->comment) {
  echo comment_render($node, $node->cid);
  $node->comment = NULL;

Put it into node.tpl.php or node- _type_.tpl.php However, you can output it in page.tpl.php too and actually, in any file, just make sure, you 're able to path correct $node to the snippet.

Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials