wp_restore_post_revision_meta()wp-includes/revision.php | Restore the revisioned meta values for a post.
|
do_all_trackbacks()wp-includes/comment.php | Performs all trackbacks.
|
do_all_enclosures()wp-includes/comment.php | Performs all enclosures.
|
do_all_pingbacks()wp-includes/comment.php | Performs all pingbacks.
|
wp_check_for_changed_dates()wp-includes/post.php | Checks for changed dates for published post objects and save the old date.
|
WP_Privacy_Policy_Content::get_suggested_policy_text()wp-admin/includes/class-wp-privacy-policy-content.php | Checks for updated, added or removed privacy policy information from plugins.
|
WP_Privacy_Policy_Content::_policy_page_updated()wp-admin/includes/class-wp-privacy-policy-content.php | Updates the cached policy info when the policy page is updated.
|
wp_privacy_process_personal_data_export_page()wp-admin/includes/privacy-tools.php | Intercept personal data exporter page Ajax responses in order to assemble the personal data export file.
|
wp_privacy_generate_personal_data_export_file()wp-admin/includes/privacy-tools.php | Generate the personal data export file.
|
WP_Customize_Manager::handle_dismiss_autosave_or_lock_request()wp-includes/class-wp-customize-manager.php | Deletes a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock.
|
_wp_delete_customize_changeset_dependent_auto_drafts()wp-includes/nav-menu.php | Deletes auto-draft posts associated with the supplied changeset.
|
WP_Customize_Nav_Menus::save_nav_menus_created_posts()wp-includes/class-wp-customize-nav-menus.php | Publishes the auto-draft posts that were created for nav menu items.
|
wp_restore_image()wp-admin/includes/image-edit.php | Restores the metadata for a given attachment.
|
Custom_Image_Header::ajax_header_remove()wp-admin/includes/class-custom-image-header.php | Given an attachment ID for a header image, unsets it as a user-uploaded header image for the active theme.
|
wp_scheduled_delete()wp-includes/functions.php | 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_Embed::delete_oembed_caches()wp-includes/class-wp-embed.php | Deletes all oEmbed caches. Unused by core as of 4.0.0.
|
set_post_thumbnail()wp-includes/post.php | Sets the post thumbnail (featured image) for the given post.
|
delete_post_thumbnail()wp-includes/post.php | Removes the thumbnail (featured image) from the given post.
|
wp_check_for_changed_slugs()wp-includes/post.php | Checks for changed slugs for published post objects and save the old slug.
|
wp_delete_attachment()wp-includes/post.php | Trashes or deletes an attachment.
|
wp_update_attachment_metadata()wp-includes/post.php | Updates metadata for an attachment.
|
wp_untrash_post_comments()wp-includes/post.php | Restores comments for a post from the Trash.
|
wp_insert_post()wp-includes/post.php | Inserts or update a post.
|
wp_delete_post()wp-includes/post.php | Trashes or deletes a post or page.
|
wp_untrash_post()wp-includes/post.php | Restores a post from the Trash.
|
update_attached_file()wp-includes/post.php | Updates attachment file path based on attachment ID.
|
wp_update_nav_menu_item()wp-includes/nav-menu.php | Saves the properties of a menu item or create a new one.
|
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
andpost_inspiration
.To delete all the keys use
delete_post_meta_by_key( $post_meta_key )
. This would be added to the “uninstall” function:Or, if you wanted to delete all the keys except where
post_inspiration
was “Sherlock Holmes”:Or maybe post number 185 was just deleted, and you want to remove all
related_posts
keys that reference it:Default Usage
Be VERY careful when using this function to delete a specific key-value pair. As stated in
delete_metadata()
‘s documentation, providing an empty string for$meta_value
will cause the check to be skipped entirely, resulting in all keys being deleted!To avoid accidentally deleting ALL key instances, use a short-circuit check:
If you want to delete all entries with a specified
meta_key
, regardless of the field value, you need to setmeta_value
asnull
, otherwise the function will returnfalse
and the field does not get deleted