Function: add_term_meta

add_term_meta( integer $term_id, string $meta_key, mixed $meta_value, boolean $unique )

Adds metadata to a term.

Shortcut: atm

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.


Name Type(s) Default Value Description
$term_id integer

Term ID.

$meta_key string

Metadata name.

$meta_value mixed

Metadata value.

$unique boolean false

Optional. Whether to bail if an entry with the same key is found for the term. Default false.


integer | WP_Error | boolean

Meta ID on success. WP_Error when term_id is ambiguous between taxonomies. False on failure.

WordPress Developer Newsletter

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