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

Function Reference/delete metadata


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


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


(string) (required) Type of object metadata is for (e.g., comment, post, or user)
Default: None
(integer) (required) ID of the object metadata is for
Default: None
(string) (required) Metadata key
Default: None
(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.
(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

True on successful delete, false on failure.

Change Log

Since: 2.9

Source File

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


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

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