is_object_in_taxonomy() WordPress Function

The is_object_in_taxonomy() function is used to check if an object (post, user, etc.) is a member of a given taxonomy.

is_object_in_taxonomy( string $object_type, string $taxonomy ) #

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


Parameters

$object_type

(string)(Required)Object type string.

$taxonomy

(string)(Required)Single taxonomy name.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/taxonomy.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, true );
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More