WordPress tip: Include comments in post lists

by Jean-Baptiste Jung on August 17, 2009

I have a hard time at first, but including inline comments on your index.php file is just really simple.
Simply paste the following code on your index.php file, where you want the comments to be displayed:

<?php
  global $withcomments;
  $withcomments = true;
  comments_template("/inline-comments.php");
?>

What I did? That's simple: On line 2, I declare that I'll use the global variable $withcomments. I then set its value to true on line 3. Finally, I use the comments_template() function to call my comments file. The /inline-comments.php parameter tells the function to use a specific file for displaying comments, instead of the regular comments.php.

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

WordPress tip: Include comments in post lists