add_term_meta() – Adds metadata to a term.

You appear to be a bot. Output may be restricted

Description

Adds metadata to a term.

Usage

$int|false|WP_Error = add_term_meta( $term_id, $meta_key, $meta_value, $unique );

Parameters

$term_id
( int ) required – Term ID.
$meta_key
( string ) required – Metadata name.
$meta_value
( mixed ) required – Metadata value. Must be serializable if non-scalar.
$unique
( bool ) optional – Optional. Whether the same key should not be added. Default false.

Returns

int|false|WP_Error Meta ID on success, false on failure. WP_Error when term_id is ambiguous between taxonomies.

Source

File name: wordpress/wp-includes/taxonomy.php
Lines:

1 to 7 of 7
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 );
}
 

 View on GitHub View on Trac