Applying and Stripping Comments from Specific Pages

Discussion in 'WordPress' started by Hawkbacker, Aug 10, 2011.

  1. #1
    I know how to strip comments from WordPress but what I'm trying to learn is how to strip comments from all other pages but then keep them on the blog page of the site. How do you do this? I know how to disable comments but this is not what I want as it doesn't look professional when you have something like "Comments Turned Off". Thanks.
     
    Hawkbacker, Aug 10, 2011 IP
  2. waziuz

    waziuz Active Member

    Messages:
    783
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    80
    #2
    You can simply put comments into moderation and then approve as per your need. And with combination of moderation queue and askimet it should work out pretty well if you do not want to turn off comments.
     
    waziuz, Aug 11, 2011 IP
  3. Hawkbacker

    Hawkbacker Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I know how to moderate comments. That is not what I am asking. I'm talking about stripping out comments on pages where I don't want them and then having where I want them, such as a blog page. Perhaps this can be controlled in page templates but I don't know.
     
    Hawkbacker, Aug 12, 2011 IP
  4. primitip

    primitip Active Member

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    60
    #4
    open page.php file of your active theme

    delete <?php comments_template(); ?>

    if you are using twentyten you can find that code on loop-page.php
     
    primitip, Aug 12, 2011 IP
  5. Hawkbacker

    Hawkbacker Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for that reply. I'll give that a whirl. Does doing that on page.php effect only pages and not posts?
     
    Hawkbacker, Aug 12, 2011 IP
  6. primitip

    primitip Active Member

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    60
    #6
    only pages

    single post view will use single.php template
     
    primitip, Aug 12, 2011 IP
  7. Hawkbacker

    Hawkbacker Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks a lot for clarifying. Very helpful. In my last project, I just ripped out all the comments code from comments.php, which has its limitations :)
     
    Hawkbacker, Aug 12, 2011 IP
  8. primitip

    primitip Active Member

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    60
    #8
    If you need to display comments on specific page, use this code in your page.php

    <?php if ( get_post_custom_values('comments') ) comments_template(); ?>

    Then on the page editor, add a custom field with key and value = "comments"
     
    primitip, Aug 12, 2011 IP