Check if a post has any term in this custom taxonomy?

You can have the term input empty, e.g.

if( has_term( '', 'genre' ) ) {
    // do something
}

to see if the current post object has any terms in the genre taxonomy.

It uses is_object_in_term() where:

The given terms are checked against the object’s terms’ term_ids,
names and slugs. Terms given as integers will only be checked against
the object’s terms’ term_ids. If no terms are given, determines if
object is associated with any terms in the given taxonomy.

Leave a Comment