is_object_in_taxonomy

The timeline below displays how wordpress function is_object_in_taxonomy has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Determines if the given object type is associated with the given taxonomy.
 *
 * @since 3.0.0
 *
 * @param string $object_type Object type string.
 * @param string $taxonomy    Single taxonomy name.
 * @return bool True if object is associated with the taxonomy, otherwise false.
 */
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);
}

WordPress Version: 5.5

/**
 * Determine if the given object type is associated with the given taxonomy.
 *
 * @since 3.0.0
 *
 * @param string $object_type Object type string.
 * @param string $taxonomy    Single taxonomy name.
 * @return bool True if object is associated with the taxonomy, otherwise false.
 */
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);
}

WordPress Version: 4.3

/**
 * Determine if the given object type is associated with the given taxonomy.
 *
 * @since 3.0.0
 *
 * @param string $object_type Object type string.
 * @param string $taxonomy    Single taxonomy name.
 * @return bool True if object is associated with the taxonomy, otherwise false.
 */
function is_object_in_taxonomy($object_type, $taxonomy)
{
    $taxonomies = get_object_taxonomies($object_type);
    if (empty($taxonomies)) {
        return false;
    }
    return in_array($taxonomy, $taxonomies);
}

WordPress Version: 4.1

/**
 * Determine if the given object type is associated with the given taxonomy.
 *
 * @since 3.0.0
 *
 * @param string $object_type Object type string
 * @param string $taxonomy Single taxonomy name
 * @return bool True if object is associated with the taxonomy, otherwise false.
 */
function is_object_in_taxonomy($object_type, $taxonomy)
{
    $taxonomies = get_object_taxonomies($object_type);
    if (empty($taxonomies)) {
        return false;
    }
    if (in_array($taxonomy, $taxonomies)) {
        return true;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Determine if the given object type is associated with the given taxonomy.
 *
 * @since 3.0.0
 * @uses get_object_taxonomies()
 *
 * @param string $object_type Object type string
 * @param string $taxonomy Single taxonomy name
 * @return bool True if object is associated with the taxonomy, otherwise false.
 */
function is_object_in_taxonomy($object_type, $taxonomy)
{
    $taxonomies = get_object_taxonomies($object_type);
    if (empty($taxonomies)) {
        return false;
    }
    if (in_array($taxonomy, $taxonomies)) {
        return true;
    }
    return false;
}