Forums

[resolved] how to shut off comments in just one category (5 posts)

  1. nadine00
    Member
    Posted 2 years ago #

    Hi

    So, I'm wondering if anyone has tried this. I've been sifting through resources and tutorials but...its not quite working. Basically I'm trying to shut the comments form off in just one category. So far i've tried making a different single page which half worked:

    <?php $post = $wp_query->post;
    if ( in_category('comics') ) {
    include(TEMPLATEPATH . '/comicSingle.php');
    } else {
    include(TEMPLATEPATH . '/single.php');
    }
    ?>

    simple enough, except it's displaying a double of the post in the bottom, under the footer w/ the normal single page comment setup.

    suggestions? I'm currently reading the 'in_category' page as well.

    thanks!

    Nadine.

  2. Mark / t31os
    Moderator
    Posted 2 years ago #

    single.php is included (or used) automaticlly, so including it creates the double problem...

    http://codex.wordpress.org/File:Template_Hierarchy.png

    Do your if in category business in the single.php file....

  3. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    You could try just amending single.php.

    <?php if(!in_category('comics')) comments_template();?>

  4. asechrest
    Member
    Posted 2 years ago #

    How about this. In comments.php:

    <?php if (!in_category(23, $post->ID)) { ?>
    
    //All of your comments code goes in here
    
    } ?>

    Obviously you'd change 23 to the cat ID of your choice. I don't think you'd need the $wp_query portion, either.

    P.S. - Tested this and it shut the comments off in cat 23 for me.

  5. nadine00
    Member
    Posted 2 years ago #

    Thanks for the suggestions, and responses. I'm still trying to figure out some of the Hierarchy things in WP. :)

    esmi, that 'if not in' statement did the trick nicely!

Topic Closed

This topic has been closed to new replies.

About this Topic