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.

  • http://www.a1000jewelsblog.com a1000jewels

    You are a legend – thanks – I have been searching to find out how to always display a comments form on pages – and this answered it!
    Many thanks
    Julie P

  • http://www.a1000jewelsblog.com a1000jewels

    However – now I have the same comment on all the pages!!
    If you can help, please feel free to do so!

  • http://clifgriffin.com clifgriffin

    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.

  • Sophia

    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.

  • http://www.fsainz.com Fernando

    perfect, just what i needed : )

  • wasabi

    You are great!!!! ;)

  • wasabi

    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?

    • http://clifgriffin.com clifgriffin

      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)

    • http://clifgriffin.com clifgriffin

      One more thing: http://ottodestruct.com/blog/2008/09/29/wordpress-27-comments-enhancements/

      This site was very helpful in my conversion to a WordPress 2.7 compatible theme.

  • http://www.jeffbrockstudio.com Jeff Brock

    THANK YOU! This saved me from a lot of client-induced anxiety! :)

  • http://www.fairfieldgreenfoodguide.com Analiese

    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!

  • http://y2.awardspace.com/021fr.html Wiffilbofophy

    exciting and informative, but would be suffering with something more on this topic?

  • http://tightandtapered.com/blog/ T

    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!

    • http://clifgriffin.com clifgriffin

      I’m not sure, honestly. You might try removing the comments template line and leaving withcomments set to 1. That may or may not work…never tested it.

  • http://www.professionalsahm.com Maureen

    Thank you so much for this post! I have spent so much time trying to figure out how to do this.

  • http://swertreshearing.suertrestoday.com swertres

    It works! Thanks…. I have been looking for this for ages!

  • Dave

    Thank you Thank you Thank you!!!

  • sv3tlio

    Than you! This tip is very useful for me.

  • http://techpp.com Raju

    Looks so simple, but never knew how to do it. thanks!!

  • http://teacherprimer.com Angela

    You rock.

  • http://mightyamy.com amy

    Thanks so much! This was very very helpful!

  • http://willdwhitedesign.com/blog_design/ Will D. White

    Thank you so much!

  • http://www.mountainbikingnewzealand.co.nz paul

    Thanks! This solved my problem just fine!!!

  • http://www.sbitllc.com/pcc wisecat74

    Thanks man.

  • Pingback: Display Comment Form on Main Index in Wordpress Clifton Griffin | Cast Iron Cookware

  • Pingback: Display Comment Form on Main Index in Wordpress Clifton Griffin | Wood TV Stand

  • Pingback: Display Comment Form on Main Index in Wordpress Clifton Griffin | Indoor Grills

  • http://www.yourdesign.co.za Michael Montgomery

    Thank’s for this piece of advice, I even solved a single.php template page issue with this code.

  • Pingback: Display Comment Form on Main Index in Wordpress « Clifton Griffin | Squico

  • http://www.spacesector.com Adam Solo

    Great! I was desperatly looking for a way to resolve this.
    Thanks alot!

  • http://blog.newmarketingway.com/ sai

    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

  • cubrikaska

    Esta idea excelente tiene que justamente a propГіsito

  • http://www.freelancersbd.com shaquibkhan

    Thanks Dude….

  • http://www.greedysnob.com Greedysnob


    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.


  • http://www.greedysnob.com Greedysnob

    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.

  • http://tipswift.com Christinamsr

    I have found it on this website called tip swift. You can find it there.
    edit: wrong thread,

  • haink

    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.

  • http://www.moshundesign.com Matt sich

    where do I put this if I want it only when someone presses a post and goes to it? single.php? I’ve tried it but it never shows up

    • http://www.moshundesign.com Matt sich

      ok, I got it to work but now it messed up my xhtml BG. =/

  • http://greateraltoonajewishfederation.org Drexel

    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?

  • http://greateraltoonajewishfederation.org/blog Drexel

    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?

  • michael


  • Naki

    It works. I thank you.

  • LG

    Can’t seem to find that line of code in the default theme of WordPress 3. Maybe it’s somewhere else?

  • Sam

    OMG! what a lifesaver!!! a client asked that i kept trying to grab it form the single post and it wasn’t working. thank goodness for this!

  • Mike

    Hello. Following your thread above I added the following two lines of code:

    ?php $withcomments = 1; ?
    ?php comments_template(); ?

    to http://texasfireframe.com/fireplace-grate-blog/ (the index.php – Main Blog Page)”

    For some reason it is pushing the RECENT POSTS/RECENT COMMENTS/ARCHIVES/ETC. down BELOW the comment box.

    It appears properly on the individual blogpost:

    Can you assist? – Much appreciated.


    Here is the entire code for index.php:

    ?php get_sidebar(); ?>?php get_footer(); ?

    ?php $withcomments = 1; ?
    ?php comments_template(); ?

  • Maria

    Thanks a lot, something so simple and yet I have spend hours on the net looking for this.

  • http://youjizzyoujizz.com Sanjay

    Thanks for the great post. I have been trying to figure how to do this for a long time. But you have made it crystal clear for me. Very much appreciated. And very simple too.

  • http://www.techwek.com Ashwin

    Hey man thanks for sharing and that to in such a simpler forum… thanks a lot.. :)

  • Toorwarboni

    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!


  • Sean Steezy

    hmmm. nothing shows up in your code on steps 2 and 3.

    • Anonymous

      Fixed. Forgot to activate a plugin. :)

  • http://codedincantation.com http://codedincantation.com

    This is helpful. Thanks for this.

  • Guy Cousineau

    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.


    • Anonymous

      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

  • Pritos

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

  • http://andywarthol.com Andrew Van Wart

    Good post. I have disqus installed and when I use your code it gives me the old comment box instead of disqus. Do you know what my issue is? http://ehrbloggers.com

    • Anonymous

      Yes i am also trying to figure this out! do you know how to yet?

      • http://andywarthol.com Andrew

        Haven’t found the solution yet, unfortunately.

  • http://www.facebook.com/Zejho Sebastian Sandell

    I’ve tried it and the comments displays just fine, but it’s the same comments on all the posts :/

  • Rahul


  • http://twitter.com/mitchalisa Alisa Mitchell

    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?

    • http://twitter.com/mitchalisa Alisa Mitchell

      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!

  • http://www.istanbularabakiralama.gen.tr/ istanbularabakiralama

    WordPress Plugins and add-on as far as I know how little we use to run I’m sure it will be as efficient as Seo. Extension-Wp run the most sense.

  • Ympervej

    Thanks that a great help.

    • http://www.facebook.com/vukhaclan Vu Khac Lan


  • Longchamp Outlet

    You most definitely have made this blog into something thats eye opening and important.

    Longchamp outlet

  • harry

    Great information