我不包括特定类别的评论。但是,当我尝试排除多个时,它不起作用。
这有效:<?php if (!in_category('7')) comments_template(); ?>
这不起作用:
<?php if (!in_category('7 , 9')) comments_template(); ?>
或
<?php if (!in_category('7')) comments_template(); ?> <?php if (!in_category('9')) comments_template(); ?>
答案 0 :(得分:2)
Wordpress有一个相当不错的文档,总是值得先研究。见Function Reference: in_category()
该函数似乎不接受多个参数,因此您必须在PHP中执行此操作:
if ((!in_category('7')) and (!in_category('9')))
答案 1 :(得分:0)
<?php
if ( !in_category('7') && !in_category('9') ) {
comments_template();
}
?>