Post Pic

WordPress tip: Include comments in post lists

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:

<?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.

Related Posts

Related Posts

No related posts.

2 Responses

Jul 20 2012 18:39

Perhaps the most vague article I’ve read on WP. Yes I can see that you set withcomments to true. What does that function do? Who knows, but you did load a file after it so that’s cool I guess…

Nov 06 2012 08:17

I found this super help, I was trying to figure out to post inline comments to posts as the standard method wasn’t working for me, cheers!

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox