is_object_in_term() WP 1.0
Determine if the given object is associated with any of the given terms.
The given terms are checked against the object's terms' term_ids, names and slugs. Terms given as integers will only be checked against the object's terms' term_ids. If no terms are given, determines if object is associated with any terms in the given taxonomy.
Works based on: wp_get_object_terms(), get_object_term_cache()
Basis of: has_term()
1 time = 0.000809s = slow | 50000 times = 1.16s = fast | PHP 7.0.8, WP 4.6.1
No Hooks.
Return
true/false/WP_Error. WP_Error on input error.
Usage
is_object_in_term( $object_id, $taxonomy, $terms );
- $object_id(int) (required)
- ID of the object (post ID, link ID, ...).
- $taxonomy(string) (required)
- Single taxonomy name.
- $terms(int/string/array)
- Term term_id, name, slug or array of said.
Default: null
Changelog
Since 2.7.0 | Introduced. |
Code of is_object_in_term() is object in term WP 5.6
Related Functions
From tag: Term (taxonomies terms)
- get_term()
- get_term_by()
- get_term_children()
- get_term_field()
- get_term_link()
- get_terms()
- get_the_term_list()
More from category: For posts
- get_object_taxonomies()
- get_objects_in_term()
- get_the_category()
- get_the_category_list()
- get_the_tag_list()
- get_the_tags()
- get_the_taxonomies()