delete_post_meta_by_key() WordPress Function

The delete_post_meta_by_key() function allows you to delete post meta data by its key. This is useful for when you want to remove specific data from a post, rather than all post meta data.

delete_post_meta_by_key( string $post_meta_key ) #

Deletes everything from post meta matching the given meta key.


Parameters

$post_meta_key

(string)(Required)Key to search for when deleting.


Top ↑

Return

(bool) Whether the post meta key was deleted from the database.


Top ↑

Source

File: wp-includes/post.php

function delete_post_meta_by_key( $post_meta_key ) {
	return delete_metadata( 'post', null, $post_meta_key, '', true );
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More