2011-05-23 45 views
0

上午排除特定類別的評論。但是,當我嘗試排除多於一個時,它不起作用。如何在這個WordPress的黑客中指定多個類別?

這工作:<?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(); ?>

回答

2

的WordPress有一個漂亮體面的文件,始終是值得研究的第一。見Function Reference: in_category()

的功能似乎並不接受多個參數,所以你必須要做到這一點在PHP中:

if ((!in_category('7')) and (!in_category('9'))) 
0
<?php 
if (!in_category('7') && !in_category('9')) { 
    comments_template(); 
} 
?> 
相關問題