Display Comment Form on Main Index in WordPress

If you want to add a comment form on your main index page in WordPress, do the following:

  1. Open your theme’s index.php file. (e.g., /wp-content/themes/whatever/index.php)
  2. Find this line:
    <?php endwhile; ?>
  3. Add these lines immediately above said line:
    <?php $withcomments = 1; ?>
    <?php comments_template(); ?>

That’s all there is to it.

Comments

  1. says

    I’m not sure I understand the problem. What do you mean by “same comment on all the pages”?

    A quick look at your site seems to indicate you now have a comment form on your main index page.

  2. Sophia says

    You are a lifesaver! I had been combing the web for a few hours for this to work. I was so determined. Thank you so much.

  3. wasabi says

    Quick question..I receive a lot of comments in my blog. Do you know a way to setup paging for the comments located in my main page?

    • says

      That is a good question. In short, it’s possible, but you’ll probably have to install a plugin that sets up paging for all comments. WordPress 2.7 can do comment paging natively, but it requires theme changes if you have a 2.6 and before theme.

      If you do not want paging on single pages and just want it on the main index, you’ll have to do something fancy. I’ll take a look at WordPress 2.7 and see if there is an easy way to do this soon. (This blog is currently running 2.7, I haven’t looked at how it does its paging closely yet, however)

  4. says

    I used your fix to display posts along with their comments on my main blog page. Thanks! One issue arose, when I tested the comment form, I discovered that the tab key doesn’t work sequentially. Instead of advancing to the next field in the comment form, it jumps to another field in a different post’s comment form on the same page. I searched online and couldn’t even find someone with the same problem. Any ideas? Thanks!

  5. says

    thanks i really appreciate the info as this seems strangely hard to find across the net. i just recently came across the same thing here: http://www.flisterz.com/2008/06/02/wordpress-display-comments-on-main-page/

    but what i am really interested in now is: how can i get only the comments to show, and not the comment input box (the “reply” form)? if people want to leave comments, they can do so on the single post page, but the reply box after every post on the main index really clutters everything up. thanks!

  6. says

    hey, mr. guru,

    THANKS so much, i was searching for this until 5am in the morning.

    article after article, video after video, trying whatever to get this to work.

    finally i came accross u. just add 2 sentence…

    thanks so much,

    i didn’t work right away. i had 2 comment boxes. i don’t know why but i did this and now it works.

    i add the more time on top just for the sake of trying and then it worked i dont know why

    so thanks Much

  7. says

    THANK YOOOOU! YOU ARE THE EFFING BEST DUDE!

    Honestly ive been looking all over for a code that does this! Most of what i found were way too complicated to attempt without screwing up my code…or they were plugins that didnt work.

    THIS WAS SO SIMPLE AND IT WORKED! I LOVE YOU!

  8. says

    I have a quick question. My blog is new, but once it gets popular, it might start getting a lot of comments and I dont want people to have to scroll through all of the comments before they get to the next post. Is there a way to leave the comments box showing, but hide the comments themselves..and maybe have it where they have to click “show comments” in order to see the comments? I love having the comments box on the main page, but i dont want the main page to be flooded with comments.

  9. haink says

    Through our connections cash advance payday you can apply fo. I didn39t have any other option for emergency cash and I39m very grateful. Cash-strapped people are all alike. Ace Cash Advance Cedar Rapids Ia – check cash advance sheffield illinois 4. nationwide cash advance LISA NEAL How does the University of Phoenix online program relate to the. I was going to use some cash and cheques but hope to rely on my Meastro Keycard.

  10. says

    Great Code. However I get the same comment over and over again for different posts. For some reason it is not rotating comments along with the post?

    Do you have any suggestions?

  11. says

    Great Code. However I get the same comment over and over again for different posts. For some reason it is not rotating comments along with the post?

    Do you have any suggestions?

  12. Toorwarboni says

    Well-paying, they desideratum to be taught that filing lawsuits is not the emulsion to ode dignity piracy. A substitute alternatively, it’s to layout something mastery than piracy. Like hypnotic of use. It’s unequivocally a a barrel easier to contemn iTunes than to search the Internet with forewarning of malware and then crappy faith, but if people are expected to add to loads and chaperon to against ages, it’s not thriving to work. They in whatever disintegrate would more a squat weigh to the fore people beget software and Network sites that amount to it ridiculously unruffled to infringer, and up the quality. If that happens, then there monody be no stopping piracy. But they’re too sharp and horrified of losing. Risks suffer with to be taken!

    Twister

  13. Guy Cousineau says

    edit POST.PHP in WP 3.x
    at the bottom of the file, add this line

    <?php $withcomments = “1″; comments_template(”, true); // Get wp-comments.php template ?>

    this will include the correct comment in ALL posts whether Archive, TAG, Main Index, etc. If that is not what you want you will need to set the withcomments variable on the pages that call the single post function.

    Guy

    • clifgriffin says

      Interesting. Wouldn’t that be wiped out by any upgrades to WP though?
      I never modify base WordPress as a rule.

      Sent from my iPad

  14. Guy Cousineau says

    edit POST.PHP in WP 3.x
    at the bottom of the file, add this line

    <?php $withcomments = “1″; comments_template(”, true); // Get wp-comments.php template ?>

    this will include the correct comment in ALL posts whether Archive, TAG, Main Index, etc. If that is not what you want you will need to set the withcomments variable on the pages that call the single post function.

    Guy

    • Clifton Griffin says

      Interesting. Wouldn’t that be wiped out by any upgrades to WP though?
      I never modify base WordPress as a rule.

      Sent from my iPad

  15. Pritos says

    Any idea how, after submitting the comment, to direct back to the main page, instead of the single post page?

  16. Pritos says

    Any idea how, after submitting the comment, to direct back to the main page, instead of the single post page?

  17. says

    This worked for me…. kind of. The comment form does show up under each post on the main page; however, when I go to the individual pages, there are about 20 comment forms in a row listed under the post. This is the same for every individual post page. What could I have done to cause this? Help, please?

    • says

      I fixed my problem. I must have left some changes I made from other
      tutorials (I tried many before I found this one) in my comments.php. I
      replaced the file with an original copy and I am back to one comment
      form per single post page. Thanks for sharing this solution– it’s the
      only one I found anywhere that actually worked!

Trackbacks

  1. [...] Display Comment Form on Main Index in WordPress Clifton Griffin Posted by root 17 hours ago (http://clifgriffin.com) Jr sr banquet a myriad of pictures middot jr sr banquet dinner and bowling if you want to add a comment form on your main index page in wordpress do the following fusion theme by digitalnature powered by wordpress Discuss  |  Bury |  News | display comment form on main index in wordpress clifton griffin [...]

  2. [...] Display Comment Form on Main Index in WordPress Clifton Griffin Posted by root 20 minutes ago (http://clifgriffin.com) Family beach trip middot final home game liberty vs vmi middot friends and family if you want to add a comment form on your main index page in wordpress do the following fusion theme by digitalnature powered by wordpress Discuss  |  Bury |  News | Display Comment Form on Main Index in WordPress Clifton Griffin [...]

Leave a Reply