In a WordPress template, sometimes you want to do something only for one single term of custom taxonomy, not for all posts using the custom taxonomy. For example, say you’ve created a custom taxonomy, ‘Fruits’ and it has some terms: bananas, oranges, apples. And say you want to do something only for posts that have ‘oranges’ as the term for the Fruit taxonomy, not simply for all posts that use the Fruit taxonomy.
Here is a conditional statement that checks to see if the current post has one specified term of a custom taxonomy.
<?php if (has_term( 'specified_term', 'custom_taxonomy' ) ) { // show special stuff for the specified term of the custom taxonomy here } ?>
On line 2 of the example above, you must change ‘specified_term’ to your own specified term. Also change ‘custom_taxonomy’ to your own taxonomy.
Questions and Comments are Welcome