Forums

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

  1. nadine00
    Member
    Posted 4 months 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. t31os_
    Member
    Posted 4 months 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
    Member
    Posted 4 months ago #

    You could try just amending single.php.

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

  4. asechrest
    Member
    Posted 4 months 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 4 months 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!

Reply

You must log in to post.

About this Topic