开发者

How do I designate more than one category in this Wordpress hack?

开发者 https://www.devze.com 2023-03-07 16:51 出处:网络
am excluding comments from specific categories. However, when I try to exclude more than one, it doesn\'t work.

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')) co开发者_开发问答mments_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(); ?>


Wordpress has a pretty decent documentation that is always worth looking into first. See Function Reference: in_category()

The function does not seem to accept multiple arguments, so you'll have to do this in PHP:

if ((!in_category('7')) and (!in_category('9')))


<?php
if ( !in_category('7') && !in_category('9') ) {
  comments_template();
}
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号