W3cubDocs

/WordPress

is_object_in_taxonomy( string $object_type, string $taxonomy ): bool

Determines if the given object type is associated with the given taxonomy.

Parameters

$object_typestringrequired
Object type string.
$taxonomystringrequired
Single taxonomy name.

Return

bool True if object is associated with the taxonomy, otherwise false.

Source

function is_object_in_taxonomy( $object_type, $taxonomy ) {
	$taxonomies = get_object_taxonomies( $object_type );
	if ( empty( $taxonomies ) ) {
		return false;
	}
	return in_array( $taxonomy, $taxonomies, true );
}

Changelog

Version Description
3.0.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_object_in_taxonomy