Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am excluding comments from specific categories. However, when I try to exclude more than one, it doesn't work.

This works: <?php if (!in_category('7')) comments_template(); ?>

This does not work:

<?php if (!in_category('7 , 9')) comments_template(); ?>

or

<?php if (!in_category('7')) comments_template(); ?>
<?php if (!in_category('9')) comments_template(); ?>
share|improve this question

2 Answers 2

up vote 2 down vote accepted

I would suggest using category slugs instead of ids. Please try something like this:

if ( ! in_category( array( 'bunnies', 'tacos', 'banana-pirates' ) ) ) {
    comments_template();
}
share|improve this answer
    
lolbbq that is awesome! –  Keith Groben May 23 '11 at 18:20

Put the IDs into an array, like this:

<?php if (!in_category(array(7, 9))) comments_template(); ?>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.