WordPress at a glance

add_term_meta() WP 1.0

Adds metadata to a term.

No Hooks.


Int/WP_Error/true/false. Meta ID on success. WP_Error when term_id is ambiguous between taxonomies. False on failure.


add_term_meta( $term_id, $meta_key, $meta_value, $unique );
$term_id(int) (required)
Term ID.
$meta_key(string) (required)
Metadata name.
$meta_value(mixed) (required)
Metadata value.
Whether to bail if an entry with the same key is found for the term.
Default: false


Since 4.4.0 Introduced.

Code of add term meta: wp-includes/taxonomy.php WP 5.4.2

function add_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) {
	if ( wp_term_is_shared( $term_id ) ) {
		return new WP_Error( 'ambiguous_term_id', __( 'Term meta cannot be added to terms that are shared between taxonomies.' ), $term_id );

	return add_metadata( 'term', $term_id, $meta_key, $meta_value, $unique );

Related Functions

From tag: Metadatas (any)

No comments
        Log In . Register