WPDev.one
Core Function
View Source on Trac ↗

delete_metadata()

delete_metadata( mixed $meta_type, mixed $object_id, mixed $meta_key, mixed $meta_value = '', mixed $delete_all = false )

Deletes metadata 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
mixed

$meta_value Optional. Metadata value. Must be serializable if non-scalar. If specified, only delete metadata entries with this value. Otherwise, delete all entries with the specified meta_key. Pass `null`, `false`, or an empty string to skip this check. (For backward compatibility, it is not possible to pass an empty string to delete those entries with an empty string for a value.) Default empty string.

Required
bool

$delete_all Optional. If true, delete matching metadata entries for all objects, ignoring the specified object_id. Otherwise, only delete matching metadata entries for the specified object_id. Default false.

Required

Return Value

(bool)
True on successful delete, false on failure.

Function Information

Since Version
2.9.0
Source File
wp-includes/meta.php
Advertisement