我已经设置了一个自定义循环,以从我创建的自定义帖子类型资源节中输出帖子。每个单独的资源都在两个不同的分类中进行了分类,一个用于资源所涉及的临床领域,另一个用于资源的类型。临床领域术语作为术语列表输出,这一切都很好。但是,我希望资源类型显示为图标(来自Font Awesome)。如果只检查了一个资源类型术语,我就可以使用它:
<?php if(has_term(\'webinar\', \'type\')) : ?>
<i class="fa fa-desktop" aria-hidden="true"></i>
<?php elseif(has_term(\'report\', \'type\')) : ?>
<i class="fa fa-file-text-o" aria-hidden="true"></i>
<?php elseif(has_term(\'video\', \'type\')) : ?>
<i class="fa fa-youtube-play" aria-hidden="true"></i>
<?php elseif(has_term(\'past-project\', \'type\')) : ?>
<i class="fa fa-cogs" aria-hidden="true"></i>
<?php elseif(has_term(\'meeting-material\', \'type\')) : ?>
<i class="fa fa-users" aria-hidden="true"></i>
<?php elseif(has_term(\'info-sheet\', \'type\')) : ?>
<i class="fa fa-info-circle" aria-hidden="true"></i>
<?php else : ?>
<i class="fa fa-link" aria-hidden="true"></i>
<?php endif; ?>
但很明显,正如我刚才愚蠢地意识到的那样,如果选择了多个术语,这是行不通的。它只检索第一个术语并输出一个图标。相反,如果选中多个术语,我希望它输出多个图标。所以我的问题是,是否有任何方法可以将其设置为一个if/AND场景,而不必构建一系列自定义has_term(array(\'webinar\', \'report\'), \'type\')
-类型语句?