Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

update_metadata()

3 tags 1 category

update_metadata() — Updates metadata for the specified object. If no value already exists for the specified object ID and metadata key, the metadata will be added. For historical reasons both the meta key and the meta value are expected to be “slashed” (slashes escaped) on input.

Inputs: $meta_type (string): Type of object metadata is for. Accepts ‘blog’, ‘post’, ‘comment’, ‘term’, ‘user’, or any other object type with an associated meta table. $object_id (int): ID of the object metadata is for. $meta_key (string): Metadata key. $meta_value (mixed): Metadata value. Must be serializable if non-scalar. $prev_value (mixed): Optional. Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries. Default empty string.

Returns int|bool: The new meta field ID if a field with the given key didn’t exist and was therefore added, true on successful update, false on failure or if the value passed to the function is the same as the one that is already in the database.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…