我正在尝试创建一个条件类,具体取决于是否在水类中找到了类。我不太了解PHP,但我认为我很接近,但仍然无法正常工作。任何帮助表示赞赏。
<?php if( has_term('water','category') ) { ?>
<p class="some-class">all water category post</p>
<?php } else { ?>
<p class="some-other-class">anything other than water category post</p>
<?php } ?>
答案 0 :(得分:1)
如果你在谈论WP has_term function
<?php if( has_term('water','category') ) { ?>
<p class="some-class">all water category post</p>
<?php } else { ?>
<p class="some-other-class">anything other than water category post</p>
<?php } ?>
如果你看不到任何结果,确保你正在调用正确的页面,那么你的代码是正确的