Support » Fixing WordPress » Display content if post has ANY term in a custom taxonomy

  • Resolved Rose

    (@eos-rose)


    I have a custom taxonomy that not every post uses. How do I word a conditional statement to display a line of text ONLY when a term (any term) from this custom taxonomy is used?

Viewing 1 replies (of 1 total)
  • I think you can use a test like this:

    $taxonomy = 'mytaxonomy';
    if (is_array($terms = get_the_terms($post->ID,$taxonomy))) {
       echo "FOUND ONE!!";
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Display content if post has ANY term in a custom taxonomy’ is closed to new replies.