[resolved] Display content if post has ANY term in a custom taxonomy (2 posts)

  1. Eos Rose
    Posted 3 years ago #

    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?

  2. vtxyzzy
    Posted 3 years ago #

    I think you can use a test like this:

    $taxonomy = 'mytaxonomy';
    if (is_array($terms = get_the_terms($post->ID,$taxonomy))) {
       echo "FOUND ONE!!";

Topic Closed

This topic has been closed to new replies.

About this Topic