Core Function
View Source on Trac ↗ update_metadata()
update_metadata(
mixed $meta_type,
mixed $object_id,
mixed $meta_key,
mixed $meta_value,
mixed $prev_value = ''
) Updates metadata for the specified object. If no value already exists for the specified object
Parameters 5 required
| Name / Type | Description |
|---|---|
| string | $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table. Required |
| $object_id int | ID of the object metadata is for. Required |
| $meta_key string | Metadata key. Required |
| $meta_value mixed | Metadata value. Must be serializable if non-scalar. Required |
| mixed | $prev_value Optional. Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries. Default empty string. Required |
Return Value
((int)
(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.
Function Information
Since Version
2.9.0
Source File
wp-includes/meta.php
Advertisement