add_metadata

SummerySummery

Adds metadata for the specified object.

Syntax

add_metadata( string $meta_type, int $object_id, string $meta_key, mixed $meta_value, bool $unique = false )

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.

$unique

(bool) (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 value: false

ReturnReturn

(int|false) The meta ID on success, false on failure.

SourceSource

File: wp-includes/meta.php


			

ChangelogChangelog

Changelog
Version Description
2.9.0 Introduced.
Scroll to Top