Enabling Comments on Every WordPress Page

Updated August 2010

Ok this might seem trivial to the smarter WordPress folks out there, but I’m dumb… dumb like a sack of rocks and didn’t just figure this out until now.

If you’ve been using WordPress for years and always wondered why the ‘Add a Comments’ section only show up on the front page of the blog and nowhere else BUT the admin interface and the rest of WordPress seem to happily support comments on every page then you are in luck.

As it turns out most (if not all?) themes I’ve used for WordPress do not include the comment-enabling snippet of code on the default Page template that is used to render sub-pages of the main site (for example, on this site, like the Contact, About, Reviews, etc. sections).

The trick is to edit the Page template (file is typically page.php) of whatever theme you are using and add the following snippet of code right below the existing post-div (ends with comment: <!–/post–>)

So find that section and right after it, add this new comments div:

<div id="comments" class="box2">
    <?php comments_template(); ?>

Update #1: The important thing here is the “<?php comments_template(); ?>” code snippet; you can actually add that anywhere you want the comment box to popup in your page inside the main content loop, it doesn’t necessarily need to be inside a comment div or after the post. That is just typically where it is placed.

You are now set, every single page on your site will include the Comments section template, and since WordPress already supports pages having comments, there is nothing more to do… it will just suddenly work.

You can see this in action (as an example) over on the kallasoft SmugMug Java API Examples page.

Hope that helps some of you WordPress’ers out there.

, , , , ,

82 Responses to Enabling Comments on Every WordPress Page

  1. Alexander August 11, 2008 at 2:20 pm #

    Thanks, I just didn´t know how to do it. Now I do. (Big relieve, because other advices could´t help me further). Once again, thanks for sharing. Regards, Alexander

    • vikas February 23, 2013 at 3:24 am #


  2. Editor August 11, 2008 at 4:30 pm #

    No problem Alexander, glad it helped.

  3. Muirshin Durkin October 30, 2008 at 1:04 am #

    Ah, after trying a few other potential solutions, this was the one that did the trick. I really needed comments to work on my pages; thanks a bundle!

  4. Riyad Kalla November 1, 2008 at 9:34 am #


    That’s great news, I’m glad it helped.

  5. Christy November 4, 2008 at 11:16 am #

    Keep a good work man!,

  6. Helen November 8, 2008 at 6:17 pm #

    Aw, man. The code technically works, but it screws up my side bar. That sucks! Thanks, though. :)

  7. Riyad Kalla November 9, 2008 at 8:24 am #


    I went to your website, the layout looks pretty standard (I wouldn’t expect the comment block to screw up the sidebar). Are you sure you added the code in the right place?

  8. John April 7, 2009 at 12:02 pm #

    Thanks man, worked great. Found this post in a Google search. Tried a different one and it didn’t work, your explanation took 45 seconds to implement and I was up and running. Really appreciate it.

  9. BAM June 6, 2009 at 11:15 am #

    how do you remove it from themes that already have it?

  10. Sergio June 15, 2009 at 2:23 pm #

    I have enabled it in every page.

    Now how is it possible to disable it from 1 page only?

    Or maybe the opposite – to enable it on one page only?


  11. Riyad Kalla June 16, 2009 at 5:02 pm #


    You can check the WP API codex and find the variable that is set when comments are enabled on a page, and then wrap that code-block with a conditional in the template editor, so depending on if you set the comments enabled in the admin interface or not, that code block that renders comments is either shown or not shown.

    Most themes support that anyway, so on that page try and disable comments (it’s under the post content box) and see if it disappears.

  12. Ramon July 1, 2009 at 8:30 pm #

    Men you saved my life. Keep up the good work.

  13. Jun-G July 29, 2009 at 9:19 pm #

    Thanks man, been looking for this solution. It really helped me a lot.
    You rock!


  14. Ivan September 15, 2009 at 6:12 am #

    Thank you! A big mystery cleared up …


  15. TheNightOwl October 23, 2009 at 5:54 am #

    Hey, Riyad

    Thanks VERY much for this. Really.

    I, too, am as dumb as a box of hammers with this kind of stuff. (Although, just quietly, between you’n’me… I really AM as dumb as a box of hammers with all this stuff and you, my friend, are NOT!)


    I just reinstalled a site and wanted to transfer all posts to Pages. This sorted it out very quickly and easily in my Theme.

    Thanks again,

  16. Gavin October 27, 2009 at 1:40 pm #

    Sorry for asking a Dumber question .
    But Where exactly do I insert this ?
    Is it in the comment.php or index.php of the default theme

    • Riyad Kalla October 28, 2009 at 11:00 pm #

      Gavin, not a dumb question at all — it’s in the Page template, usually page.php or something like that — you just pop the snippet in there and then standard pages (rendered using the ‘page.php’ file) will show the comments box!

      • Saqib August 6, 2010 at 3:59 pm #

        good post

  17. Saidul November 16, 2009 at 8:47 pm #

    O man I am really appreciate you save my 50 bucks. I was going to hire some one but I found that. thanks again

  18. MarkmafiawarsCheats November 24, 2009 at 5:28 pm #

    Thanks for the code!

    How about comments on front page? I cannot find any help with this. I get comments on secondary pages only.

    • Riyad Kalla November 25, 2009 at 9:22 am #

      Mark, you’d just have to edit the index.php or page.php templates to include comments on the home page.

  19. Vikas Gupta December 9, 2009 at 7:35 am #

    I just shifted from wordpress.com to .org and did the trick. The comment box shows but how to show the comments on each page that were already there??!! Thanks a lot for help.

  20. kiezel January 12, 2010 at 8:00 am #

    I just added the code to index.php (but couldn’t find the right location), because I don’t have a page.php but it didn’t help..

  21. Lisy January 19, 2010 at 7:14 pm #

    It worked, but I’m getting the following (right below the comment box):

    XHTML: You can use these tags:

    How do I get rid of that XHTML?

  22. Riyad Kalla January 19, 2010 at 7:18 pm #


    Dollars to donuts that your theme is the one styling your “comments” code block to look like that. So wherever you tell wordpress “insert the comment box here” that comes in with it.

    If you login to the admin panel, go to Appearance > Edit, then select the “comments.php” template, I bet that text will be in there. If you remove it, you will no longer see it.

    If you aren’t familiar with HTML you will likely see junk like “<” and “>” instead of a clear-cut a-href link… that’s just because they are using the character-codes for ‘less than’ and ‘greater than’ (respectively) so instead of rendering an actual link, it shows you the text FOR a link.

    Hope that helps!

  23. Tony March 14, 2010 at 5:12 pm #

    Thanks alot for sharing this, it’s helped alot to have a commentbox on pages….


  24. 2leep March 14, 2010 at 7:29 pm #

    thankx for the article the comments did also helped me

  25. Anonymous April 9, 2010 at 1:31 pm #

    OMG thank you!

  26. Anonymous April 11, 2010 at 12:35 pm #

    Thanks! That worked for me!

  27. Anonymous April 11, 2010 at 12:51 pm #

    Wonderfull Thanks!

  28. Anonymous May 7, 2010 at 7:55 am #

    just wanted to say thanks for this – jumped into an existing site to redesign it and couldn’t figure it out. saved me a lot of time!

  29. Riyad Kalla May 7, 2010 at 9:35 am #

    No prob Anon, glad it helped!

  30. Yunieski June 17, 2010 at 6:49 am #

    I am wonering something related with this, i have created some other pages in my wordpress like, about us, help, …but i donñt want conments to appear in those pages. What could i do to solve that problem.

    • Riyad Kalla June 17, 2010 at 9:42 am #


      Good question — when you edit the main page template and added the comments to it, that means every single page that uses that actual PHP template will have comments — this includes all custom pages you create like About, Contact, etc.

      What you want to do is copy the page template to another template file, like page-nocomments.php and then on your About and Contact pages, in the dropdown on the right hand side where you select the “template” to use for the page, you select “page-nocomment” for that template — so that page will be rendered using that page template that doesn’t include the comment block.

      NOTE: WordPress uses a certain comment-format at the top of the page template files to determine the name that displays in the dropdown in the page-editing interface… so at the top of the template page you’ll see a name in a simple comment at the top, you’ll want to change it for the page-nocomment.php file so it doesn’t also show up in the template drop down as another “page” template and then you can’t tell them apart.

  31. adrian July 5, 2010 at 1:31 pm #

    Can you tell me on wich php file have to put the code ?
    wp-content/themes/worn-wall/*. php?

    on template.php i can’t find )

    thank you


    • Riyad Kalla July 5, 2010 at 4:36 pm #

      adrian, you put that code in any template that you want to start showing comments. So if you wanted to edit your page.php template for example that is used to display simple pages, then you would add it in there. If you wanted to edit the template that displays single posts, then that is single.php

      You’ll notice when you are making a post, over in the right hand side of WordPress in the “Template” dropdown you can actually select the PHP template file you want to render the page, that is how you can tell which template you’ll want to edit.

  32. Mike Carter September 3, 2010 at 10:38 am #

    Wow! Did this help! Had NO idea how to enable comments in Pages. Great debt. Also, to Riyad Kalla for the “put anywhere” tip.

    • Riyad Kalla September 3, 2010 at 10:45 am #


      Glad it helped!

      • Mike Carter September 3, 2010 at 11:09 am #

        Riyad, would you do me a favor? Will take you about 3 min.

  33. Wolf Leonard September 5, 2010 at 3:18 pm #

    Yours was a nice simple solution to a simple problem. Thanks Riyad ! ‘Wish it were all that cut and dry.

    • Riyad Kalla September 6, 2010 at 12:07 pm #


      Thanks for the kind words, glad it helped!

  34. Sattu September 9, 2010 at 7:31 pm #

    You rock dude. You saved me. I love u 😉

  35. Vipul September 12, 2010 at 10:46 am #


    Great blog you have here. Well my query is not related to this post, but I was wondering if there is an easy way to achieve the blog posts similar to yours. For instance, how to go around displaying the summary of a post and later “Click here to read the full story” and “comments”


    • Riyad Kalla September 12, 2010 at 9:30 pm #

      Thank you Vipul. Actually that is all thanks to the guys over at WooThemes, if you are looking for a nice WordPress theme for your site, they are the leaders in the space — you can also look at Thesis Theme over at DIYThemes. Between those two groups, they have like 80% of the commercial wordpress market of awesome themes from what I can tell.

      I love WooThemes, have been a customer for years. This particular theme on the site is the “Canvas” theme, it’s not that graphically intense, but it’s super customizable.

      • Vipul September 12, 2010 at 9:47 pm #

        That’s amazing!! I loved the way you have set your homepage :)

        • Riyad Kalla September 12, 2010 at 9:56 pm #

          Well thank you Vipul, we are glad you like it. If you do end up purchasing Canvas, that is the “Magazine” layout on the front page, with the slider activated (the stories rotating at the top) then 4 “full width” stories, and then all the rest of them are crunched down to the 2 column layout to make for easier browsing.

          Hope that helps!

  36. Lianne September 12, 2010 at 2:22 pm #

    Hello Riyad,

    Thanks for the post about ‘comment on a page’.

    I have a question: I displays all comments on every page, but I would like it to show only the comments that belong to the page (filter the comments people wrote on a particular page). Is this possible?

    • Riyad Kalla September 12, 2010 at 9:46 pm #


      By default comments in WordPress have a parent “post” (posts or pages) that they belong to… I haven’t seen a theme before that just spits out a flat list of ALL comments, all the ones I’ve ever seen only show the list of comments for the page you are currently viewing.

      Which theme are you using? Is it possible you are mistaking this behavior? Post a link to your site so I can take a peek please.

      • Lianne September 20, 2010 at 4:12 am #


        Thank you for the reply. My url is: http://www.worldtrip2011.com/wordpress/

        My comments show only on the page where they’re posted, so that problem is solved. I did a test on: http://www.worldtrip2011.com/wordpress/our-stories/scheveningen/
        The only problem is that a comment on a page (instead of a post) doesn’t show under the ‘recent comments’?

        Maybe you can help me with this one.

        • Riyad Kalla September 20, 2010 at 6:44 am #


          I think that *might* be a red herring… you are running WP-SuperCache, which will refresh the cached page the comment was made to, but if you are viewing the “Recent Comments” list on another page from the one you commented on (e.g. the home page) you might see that stale list for a while.

          Try and disable WP-SuperCache, make a test comment on a Page, and see if it shows up.

          I’m not sure what the snippet of code in “Recent Comments” is doing, but my guess is it’s just polling the comment table for the last X number of comments, so that should be working.

  37. Taly Emmanuela September 17, 2010 at 2:20 pm #

    It worked but there is one small problem, I’ve made a test posting a comment and it didn’t appear on the page. I’ve already approve the comment but it still doesn’t work.. =/

    • Riyad Kalla September 17, 2010 at 2:58 pm #


      Strange. Got a link to the page handy where I can take a look?

      Also, which template PHP file did you edit and what snippet of code did you add and where?

      If you could http://pastebin.org 10 or 15 lines around the part where you inserted the snippet that might give me enough context to take a look.

      REMINDER: Also forgot, if you are running SuperCache, W3 Total Cache or anything like that, try and disable it or dump the cache and recheck the comment still isn’t there. It might just be a cache setting not refreshing on comment.

      • Taly Emmanuela September 18, 2010 at 1:51 am #

        The link to the page is here http://guillaumeparra.com/free-training/

        And the link to the code which is inside page.php: http://pastebin.org/958165

        Thank you Riyad, sorry for the trouble!

        • Riyad Kalla September 18, 2010 at 7:11 am #


          I think something is wrong with the form actually creating the comment — if you go to the “Comments” section in the admin interface, do you see my comment from “asd”?

          I just commented, and then the page refreshed and I checked the “Comments” widget in the top sidebar to see if it lists my comment as the last comment made and it doesn’t.

          Also checked and don’t see any WP-SuperCache or W3 Total Cache markers in your resultant pages, so it doesn’t seem to be a cache issue.

          So I just need you to check if that comment actually got created in the admin interface and if the /free-training post was corrected set as it’s parent?

          • Taly Emmanuela September 18, 2010 at 8:07 am #

            Your comment is there and its in /free-training.

            I’ve tried to check the first box of the sidebar on the tab Comments and all the comments are there!!! and the funny thing is that f you go on http://guillaumeparra.com/hello-world/#comment-1 the comments appear but I guess is because it is a post not a page.

            Do you have an idea of what might be the problem?

            • Riyad Kalla September 18, 2010 at 8:41 am #


              I got an idea — switch back to the “WordPress Default” theme and see if the comments are suddenly showing up correctly on the correct stories and pages.

              That will help us narrow down if the problem is our code snippet or the theme.

              • Taly Emmanuela September 19, 2010 at 2:40 pm #

                You were right, I’ve tried several themes and some of them the comments are there and some of them they aren’t…

                I’ll contact the theme author or change the theme! Thank you so much for the help, anyway the snipet was very helpful!

                cheers =)

                • Riyad Kalla September 19, 2010 at 8:19 pm #


                  Excellent. Glad I could help.

  38. Paul November 2, 2010 at 1:06 pm #

    OK I have enabled comments and created a comments / no-comments template
    However comments made on one page show up on other comment enabled pages even though they were not originally posted on that page.

    http://www.sarahhaynes.me.uk/Blog/reviews/ page where comments originally posted

    http://www.sarahhaynes.me.uk/Blog/q-a/ page showing same comments

    I am pretty unfamiliar with the technical aspects of WP so any pointers as to where to look / fix would be helpful


    • Riyad Kalla November 3, 2010 at 1:23 pm #

      Paul, what does the code in your template look like for pulling comments?

      If you login to the WP admin interface and go to “Comments” section, are those comments correctly associated with *different* pages, or are they associated with both those pages?

      In the right hand column, under “In Response To” is what I”m asking about, I wonder if the relationship is messed up.

  39. avoitrarl November 5, 2010 at 7:32 am #

    Download for free all content from site http://ero2you.unextwarez.com
    Its really free VIDEO only for you!
    Public sex, amateur sex video, straight sex, young teens fucks!
    All free content for you in full videos http://ero2you.unextwarez.com


  40. Sexy wallpaper January 5, 2011 at 1:33 am #

    yeah great info.. like it

  41. Rozeman March 24, 2011 at 1:12 am #

    Hello Mr Riyad Kalla.. found you article via Google.. Thank you. really helped me a lot..

  42. sandbad June 18, 2011 at 7:33 am #

    i add the code. but nothing change .the box comment doesn’t show . i hope you can help more about

    this is my blog http://www.acnientbabyloncivilization.com

  43. Marc June 20, 2011 at 5:11 pm #

    I’m a bit nervous about doing this since I totally wrecked a page after messing with a php file. Nevertheless, this is an important tool and I need it. Unfortunately, when I looked in page.php, I did not find anything that ended with )
    Don’t get mad at me for posting this whole thing, but here is my page.php. I hope it shows up properly. Where in here would I add your code?

    <div class="post" id="post-“>

    <a href="” title=””>

    <?php link_pages('Pages: ‘, ”, ‘number’); ?>

    <?php edit_post_link('Edit', '’, ”); ?>

    <div class="post" id="post-“>

    • Marc June 20, 2011 at 5:12 pm #

      Doesn’t look like all of the code published. Do you accept paypal? What would you charge to do it for me?

      • Riyad Kalla June 21, 2011 at 5:45 am #

        Marc, you can use pastebin to try and share code and I’ll take a peek.

        • Marc June 21, 2011 at 6:00 am #

          Thank you. Actually, I just went for it and pasted your code onto the page.php and it seems to be working! I haven’t tested, yet, to see where the comments will go but so far, so good. Thanks again :-)

          • Riyad Kalla June 21, 2011 at 6:18 am #

            Marc, very cool I’m glad it’s working so far.

  44. tariq iqbal September 1, 2011 at 11:08 am #

    Thanks! That worked for me!


  45. Robert August 9, 2012 at 2:40 am #

    Excellent! I was afraid I’d be Google searching for hours. Seems to have done the trick!

  46. fake oakleys sale cheap April 15, 2013 at 12:15 am #

    Those who are new to jogging for exercise may be surprised to know that spending a fortune on running shoes in not necessary. A simple, inexpensive pair of athletic shoes will be up for the task. The fancy, space-age shoes are great but they really are only meant if you run competitively. If you happen to be jogging several miles everyday then buying them is an investment that is worth every penny. fake oakleys sale cheap http://www.soahostore.co

  47. Small business bookkeeping services, online bookkeeping sirvice April 18, 2013 at 7:03 am #

    Thats the plugin I was talking about.Where I would take minor exception is the using a h1 tag on a logo as that seems to be a waste of a perfectly good h1 tag. Instead, an effective and more relevant h1 should give a the viewer and search engines a brief description of what’s on the page from a content perspective. I’m not sure many company names do that and I would bet that your search results would be better served as well. Nice article though.

  48. Ron April 26, 2013 at 8:41 pm #

    Just what I was looking for a comment section of my blog theme that had no comment section.

    Nice code Thank You.

  49. Dhruv June 27, 2013 at 5:16 am #

    Hi Riyad,
    I opened the example link but it doesn’t contain the comment section. Is there any thing wrong with the trick or have you disabled it on the example page?

  50. Toptan Karanfil February 20, 2014 at 5:48 am #

    Thank you very useful information

  51. Bryant September 11, 2014 at 8:29 pm #

    Howdy! Someone in my Myspace group sshared this website with us so I came to
    guve it a look. I’m definitely loving the information.
    I’m book-marking and will be tweeting this to my followers!
    Outstanding blog and superb style aand design.

    Heere is my website; facebook

  52. Kaye Rey November 12, 2014 at 10:35 pm #

    Hi, this is a great post and it worked for most. However, it has not worked for mine. Could you kindly help. My blog is http://www.babetravelling.com

  53. Fanny August 28, 2015 at 5:08 pm #

    thanks! worked for me :)


  1. Fernando E - March 22, 2009

    http://tinyurl.com/67r8te i heart learning something new everyday. Comments for the masses!

Leave a Reply