WordPress at a glance

add_term_meta() WP 1.0

Adds metadata to a term.

No Hooks.

Return

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

Usage

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.
$unique(true/false)
Whether to bail if an entry with the same key is found for the term.
Default: false

Code of add_term_meta: wp-includes/taxonomy.php VER 5.0.1

<?php
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
    Hello, !     Log In . Register