WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Eos Rose
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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