WordPress at Your Fingertips

is_object_in_taxonomy() WP 1.0

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

1 time — 0.000029 sec (very fast) | 50000 times — 0.24 sec (very fast) | PHP 7.1.1, WP 4.7.2

No Hooks.

Return

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

Usage

is_object_in_taxonomy( $object_type, $taxonomy );
$object_type(string) (required)
Object type string.
$taxonomy(string) (required)
Single taxonomy name.

Changelog

Since 3.0.0 Introduced.

Code of is_object_in_taxonomy() WP 5.8.1

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 );
}

For posts

No comments
    Log In