WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/delete metadata

Description

Delete metadata for the specified object.

Calls 'delete_{$meta_type}_meta' after deleting with meta_id of deleted metadata entries, object ID, meta key, and meta value

Usage

<?php delete_metadata $meta_type$object_id$meta_key$meta_value$delete_all ?>

Parameters

$meta_type
(string) (required) Type of object metadata is for (e.g., comment, post, or user)
Default: None
$object_id
(integer) (required) ID of the object metadata is for
Default: None
$meta_key
(string) (required) Metadata key
Default: None
$meta_value
(string) (optional) 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:
$delete_all
(boolean) (optional) Optional, default is false. 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

Return Values

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

Change Log

Since: 2.9

Source File

delete_metadata() is located in wp-includes/meta.php

Related

Metadata API: add_metadata(), get_metadata(), update_metadata(), delete_metadata()

See also index of Function Reference and index of Template Tags.