Function: get_object_term_cache

get_object_term_cache( integer $id, string $taxonomy )

Retrieves the taxonomy relationship to the term object id.

Shortcut: gotc

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

Upstream functions (like get_the_terms() and is_object_in_term()) are responsible for populating the object-term relationship cache. The current function only fetches relationship data that is already in the cache.


Name Type(s) Default Value Description
$id integer

Term object ID.

$taxonomy string

Taxonomy name.


boolean | array | WP_Error

Array of WP_Term objects, if cached. False if cache is empty for $taxonomy and $id. WP_Error if get_term() returns an error object for any term.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.