Support » Fixing WordPress » Removing comment-field from specific pages

  • Hi everybody.

    As my blog is not really a blog, I have worked a lot on adjusting various aspects of my theme and WordPress-version to better fit my needs. One of those things was to have comments in ordinary pages. Problem is, some of my pages (Home, About) are not supposed to have comments. I have simply copied the following:

    <?php comments_template(); ?>

    …From single.php and pasted it in page.php. This naturally enables comments for all of the pages on the site. Question being; how do I disable a few selected pages from having them?

Viewing 5 replies - 1 through 5 (of 5 total)
  • http://codex.wordpress.org/Conditional_Tags

    you’ll want to use conditional comments calling specific pages.

    Or, I think another way that also could work, get something like the RunPHP plugin
    http://wordpress.org/extend/plugins/runphp/

    Then you should be able to put the template tag function code
    <?php comments_template(); ?>
    right into the body content of your Page (for example probably the last line of your page).

    Instead of putting it in the template

    Or you could have two page templates, the regular one without comments, and one with comments.

    In your theme folder, you will have
    1 – page.php (as it was before, without <?php comments_template(); ?>)

    2 – page-comments.php (a copy of page.php, but with <?php comments_template(); ?>. At the very top of that template, add this
    to create the template

    <?php /*
    	Template Name: Allow Comments
    */ ?>

    When you create a page that you want comments on, from the attributes select the “Allow Comments” template.

    Or you could have two page templates, the regular one without comments, and one with comments.

    Worked like a charm. Thanks buddha, and thanks to the rest of you as well.

    Edit: Double

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Removing comment-field from specific pages’ is closed to new replies.