Ready to get started?Download WordPress


Function Reference/update metadata



Update metadata for the specified object. If no value already exists for the specified object ID and metadata key, the metadata will be added.

Calls 'update_{$meta_type}_meta' before updating metadata with meta_id of metadata entry to update, object ID, meta key, and meta value

Calls 'updated_{$meta_type}_meta' after updating metadata with meta_id of updated metadata entry, object ID, meta key, and meta value


(string) (required) Type of object metadata is for (e.g., comment, post, or user)
Default: None
(integer) (required) ID of the object metadata is for
Default: None
(string) (required) Metadata key
Default: None
(string) (required) Metadata value
Default: None
(string) (optional) If specified, only update existing metadata entries with the specified value. Otherwise, update all entries.
Default: empty string

Return Values

True on successful update, false on failure.

Change Log

Since: 2.9

Source File

update_metadata() is located in wp-includes/meta.php


Metadata API: add_metadata(), get_metadata(), update_metadata(), delete_metadata()

See also index of Function Reference and index of Template Tags.