wppaste
WordPress

delete_post_meta( int $post_id, string $meta_key, mixed $meta_value = '' ): bool

Since
1.5.0
Source
wp-includes/post.php:2718
Deletes a post meta field for the given post ID.

Description

You can match based on the key, or key and value. Removing based on key and value, will keep from removing duplicate metadata with the same key. It also allows removing all metadata matching the key, if needed. For historical reasons both the meta key and the meta value are expected to be "slashed" (slashes escaped) on input.

Parameters

$post_idint
Post ID.
$meta_keystring
Metadata name.
$meta_valuemixedoptional
Metadata value. If provided, rows will only be removed that match the value. Must be serializable if non-scalar. Default empty.Default: ''

Return

bool
True on success, false on failure.

Uses · 2

Used by · 28

Show all 28

Source

function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {	// Make sure meta is deleted from the post, not from a revision.	$the_post = wp_is_post_revision( $post_id );	if ( $the_post ) {		$post_id = $the_post;	} 	return delete_metadata( 'post', $post_id, $meta_key, $meta_value );}

History

Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.