DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

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.

2 Comments

  1. 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…

  2. 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!

Leave a Comment

Your email address will not be published. Required fields are marked *