add_metadata


add_metadata ( $meta_type, $object_id, $meta_key, $meta_value, $unique = false )

Parameters:
  • (string) meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.
  • (int) object_id ID of the object metadata is for.
  • (string) meta_key Metadata key.
  • (mixed) meta_value Metadata value. Arrays and objects are stored as serialized data and will be returned as the same type when retrieved. Other data types will be stored as strings in the database: - false is stored and retrieved as an empty string ('') - true is stored and retrieved as '1' - numbers (both integer and float) are stored and retrieved as strings Must be serializable if non-scalar.
  • (bool) unique Optional. Whether the specified metadata key should be unique for the object. If true, and the object already has a value for the specified metadata key, no change will be made. Default false.
Returns:
  • (int|false) The meta ID on success, false on failure.
Defined at:

Description

Adds metadata for the specified object.

Related Functions

add_meta, get_metadata, delete_metadata, update_metadata, wp_read_audio_metadata

Top Google Results

User discussions

wpseek mobile