How to disable comment on a WordPress page or post

Last modified on 10th March, 2006

This is a simple tip to help you exclude the comment template on certain pages or posts in your blog. Certain themes will have the comment template unavailable by default on their pages such as those with the single.php. Some other themes will require a small change to their index.php or single.php to disable this comment section.

Here it goes:

Disable comment on certain post.


  1. Login to you WordPress administration panel, then go to Presentation > Theme Editor.
  2. Open index.php or single.php and look for the line <?php comments_template(); ?>
  3. Change it to


    <?php if (!is_single("personal-details")) {comments_template();} ?>


    This instruction disables the comment template on a post slug entitled “personal-details” without the quotation mark.

  4. Press “Update File” and presto! The comment section on that page is disabled.


Disable comment on certain pages.

  1. If you have index.php page only and you want to exclude comments on certain pages. Repeat steps 1 and 2 above.
  2. But now change <?php comments_template(); ?> to

    <?php if (!is_page("contact") and !is_page("partners") and !is_page("Add link") ) {comments_template();} ?>

    This instruction prevents the comment template to be displayed on the “contact”, “partners” and “Add link” page. Check those pages on Sabahan.com and compare them with the “About” page. You’ll notice that the comments section is not available on that three pages.

  3. Update your index.php file to complete the process.

I am not a PHP programmer but this is easy enough to implement and it works for Sabahan.com and my other blogs using WordPress version 1.5 and 2.0.1 . If you know a better way of doing this, please leave your comment and share it with us. Cheers!


Update: As suggested my LcF below, another way of doing this is my placing the following code in your index.php page so that your comment template appears only when comment is enabled.


<?php if ('open' == $post-> comment_status) {

Related Posts
No related posts for this content

  • ZEO says:

    Dude, why don’t u just edit the page and untick ‘Allow Comments’ and ‘Allow Pings’ under Discussion block?

  • LcF says:

    An easier way is to check comment is enable or not for the post/page, then show comment template if comment is enable.

    Sample code:
    if (‘open’ == $post-> comment_status) {

  • Gaman says:

    Hi ZEO,

    Yes you can do that but you will get the “No Comments” and “No comments yet” message at the bottom of your page.

    If you don’t mind that, by all means you can simply untick the ‘Allow Comments’ checkbox.

    For my purpose though, I made several changes to my comment template so even if the comment is unticked, the changes will still be visible.

    LcF, nice tip.

  • mael says:

    Hi guys,

    I’ve tried this and it’s work.

    Firstly, login to your admin site. click the Presentation tab. In the Theme Edetor tab, search for index.php file.

    Look for the below paragraph


    Tags: Tags: to disable the comment function.

  • Cassie says:

    I just edited page.php and replaced


    comment_status) {

    Worked like a charm, thank you!

  • […] as the ever popular “resume” or “about me” pages, you may want to checkout this post on removing the comments section from the bottom of a post.  If you see any customization on my […]

  • Simon Liew says:

    Thanks for sharing this useful information. Its working fine in my blog.

  • Shahid says:

    To hide the comments at specific page please change


    in page.php


  • ahmed says:

    it didnt work with me
    i use minimatica theme
    so i dont have
    presentation tab
    but i accessed index file
    but i dont have

    i have

    get_header(); ?>

  • >
    Scroll Up