delete_post_meta( int $post_id, string $meta_key, mixed $meta_value = '' ): bool
- Since
- 1.5.0
- Source
wp-includes/post.php:2679
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
- wp_is_post_revision()Determines if the specified post is a revision.
- delete_metadata()Deletes metadata for the specified object.
Used by · 27
- Custom_Image_Header::ajax_header_remove()Given an attachment ID for a header image, unsets it as a user-uploaded header image for the active theme.
- WP_Customize_Manager::handle_dismiss_autosave_or_lock_request()Deletes a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock.
- WP_Customize_Nav_Menus::save_nav_menus_created_posts()Publishes the auto-draft posts that were created for nav menu items.
- WP_Embed::delete_oembed_caches()Deletes all oEmbed caches. Unused by core as of 4.0.0.
- WP_Privacy_Policy_Content::_policy_page_updated()Updates the cached policy info when the policy page is updated.
- WP_Privacy_Policy_Content::get_suggested_policy_text()Checks for updated, added or removed privacy policy information from plugins.
- _wp_delete_customize_changeset_dependent_auto_drafts()Deletes auto-draft posts associated with the supplied changeset.
- delete_post_thumbnail()Removes the thumbnail (featured image) from the given post.
- do_all_enclosures()Performs all enclosures.
- do_all_pingbacks()Performs all pingbacks.
- do_all_trackbacks()Performs all trackbacks.
- set_post_thumbnail()Sets the post thumbnail (featured image) for the given post.
Show all 27
- update_attached_file()Updates attachment file path based on attachment ID.
- wp_check_for_changed_dates()Checks for changed dates for published post objects and save the old date.
- wp_check_for_changed_slugs()Checks for changed slugs for published post objects and save the old slug.
- wp_delete_attachment()Trashes or deletes an attachment.
- wp_delete_post()Trashes or deletes a post or page.
- wp_insert_post()Inserts or update a post.
- wp_privacy_generate_personal_data_export_file()Generate the personal data export file.
- wp_privacy_process_personal_data_export_page()Intercept personal data exporter page Ajax responses in order to assemble the personal data export file.
- wp_restore_image()Restores the metadata for a given attachment.
- wp_restore_post_revision_meta()Restore the revisioned meta values for a post.
- wp_scheduled_delete()Permanently deletes comments or posts of any type that have held a status of 'trash' for the number of days defined in EMPTY_TRASH_DAYS.
- wp_untrash_post()Restores a post from the Trash.
- wp_untrash_post_comments()Restores comments for a post from the Trash.
- wp_update_attachment_metadata()Updates metadata for an attachment.
- wp_update_nav_menu_item()Saves the properties of a menu item or create a new one.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 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.