has_term() function


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. function has_term($term_name, $taxonomy_name) {
  3. $terms = get_terms($taxonomy_name, 'fields=names');
  4. for ($i=0; $i < count($terms); $i++) {
  5. if ($terms[$i] == $term_name) {
  6. return true;
  7. }
  8. } return false;
  9. }
  10. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.