WordPress tip: Include comments in post lists

August 17, 2009 at 9:21 am

Many “new generation” themes, as such as P2 include a nice feature named “inline comments”: The option of having comments displayed in your index.php file. Let’s see how to do it.

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:

  global $withcomments;
  $withcomments = true; 

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.