update_metadata

SummerySummery

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

Syntax

update_metadata( string $meta_type, int $object_id, string $meta_key, mixed $meta_value, mixed $prev_value = '' )

ParametersParameters

$meta_type

(string) (Required) Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.

$object_id

(int) (Required) ID of the object metadata is for.

$meta_key

(string) (Required) Metadata key.

$meta_value

(mixed) (Required) Metadata value. Must be serializable if non-scalar.

$prev_value

(mixed) (Optional) If specified, only update existing metadata entries with this value. Otherwise, update all entries.

Default value: ''

ReturnReturn

(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.

SourceSource

File: wp-includes/meta.php


			

ChangelogChangelog

Changelog
Version Description
2.9.0 Introduced.
Scroll to Top