WordPress at a glance

is_object_in_taxonomy() WP 1.0

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

Works based on: get_object_taxonomies()
✈ 1 time = 0.000029s = very fast | 50000 times = 0.24s = 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.

Code of is_object_in_taxonomy: wp-includes/taxonomy.php VER 5.0.1

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

Related Functions

From category: For posts

No comments
    Hello, !     Log In . Register