Support » Installing WordPress » Disable Comments on Pages

  • A new template I am working with has comments on individual pages.
    I wanted to know, how do I disable this? Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Edit ‘single.php’ (or whatever the name of your templatefile is), delete the comment tags.

    Thank you!

    For Pages the default template is page.php (not single.php).

    Ops that’s right, thanks for the correction, moshu.

    We’ve got a similar problem, which this doesn’t seem to solve.

    Our aim is to keep comments on posts, but not have any commenting on pages (not even a “No Comments Sorry, the comment form is closed at this time.” section at the bottom.)

    In the theme we’re using, we’ve tried removing the “<?php comments_template(); // Get wp-comments.php template ?>” line in index.php but this hides comments from everything. Is there something we can put around this to say “if page is a post then show comments else don't?

    (The theme does not have a seperate page.php)

    The simplest approach would be to copy index.php to page.php and make it a proper Page Template (see [[Pages]).

    Or, if you’re more or a coder type, have a look at Conditional_Tags.

    I have looked at the Conditional_Tags codex, but I cant see (maybe I’m just dumb) how to disable comments on pages but leave them on posts.

    Please please help!

    Jay

    B

    (@eiabergm)

    Oh, old post and still open. Here’s how to do it.

    1. Open your theme’s index.php file.
    /wp-content/themes/YOURTHEME/index.php

    2. Find

    <?php comments_template(); // Get wp-comments.php template ?>

    3. Replace with:

    <?php //let's show something else than comments on pages
    if (is_page()) {
    echo 'Some text';
    	} else {
    comments_template(); // Get wp-comments.php template
    }
    ?>

    4. You can replace ‘Some text’ with anything you want. If you want it to be blank, just use ”.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Disable Comments on Pages’ is closed to new replies.