嗨,我对php/wordpress有点问题,找不到答案。
当设置了自定义分类法中的任何内容时,我想显示一个列表和一个<li>
:
<li class="">Taste: <span><a href="#"><?php printRecipeTaste($post_ID); ?></a></span></li>
我在另一个<li>
中有一些php,它可以像我想要的那样工作,但只适用于meta:
<?php if ( get_post_meta( get_the_ID(), 'iba', true ) ) : ?>
<img class="iba" src="<?php echo esc_url(home_url('/')); ?>/images/iba.jpg" alt="" />
<?php endif; ?>
我尝试过get taxonomy_exists和is_taxonomy,但我失败了。
有人能帮忙吗?Ty.
您应该能够使用get_the_terms($id, $taxonomy)
。如果帖子中没有附加该分类法的术语,则返回false。
https://codex.wordpress.org/Function_Reference/get_the_terms