Function: get_the_terms

get_the_terms( integer | WP_Post $post, string $taxonomy )

Retrieve the terms of the taxonomy that are attached to the post.

Shortcut: gtt

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.

Parameters

Name Type(s) Default Value Description
$post integer | WP_Post

Post ID or object.

$taxonomy string

Taxonomy name.

Returns

array<mixed,WP_Term> | false | WP_Error

Array of WP_Term objects on success, false if there are no terms or the post does not exist, WP_Error on failure.

WordPress Developer Newsletter

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