Parameters

(mixed) (optional) The value of the field you will delete. This is used to differentiate between several fields with the same key. If left blank, all fields with the given key will be deleted.

Default: Empty

Return values

(boolean)

False for failure. True for success.

Examples

Default Usage

<?php delete_post_meta(76, 'my_key', 'Steve'); ?>

Other Examples

Let's assume we had a plugin that added some meta values to posts, but now when we are uninstalling the plugin, we want to delete all the post meta keys that the plugin added. Assuming the plugin added the keys related_posts and post_inspiration.

To delete all the keys use delete_post_meta_by_key( $post_meta_key ). This would be added to the "uninstall" function:

<?php delete_post_meta_by_key( 'related_posts' ); ?>

Or, if you wanted to delete all the keys except where post_inspiration was "Sherlock Holmes":