WordPress action hook
delete_post_meta
Fired by 9 WordPress plugins, running on 10M+ sites between them.
“Core's hook before post meta is deleted, as delete_metadata() fires it.”
How to use delete_post_meta
It's an action: your callback runs at that point and receives 4 arguments. Nothing needs to be returned.
Add this to your theme's functions.php or a small custom plugin:
add_action( 'delete_post_meta', function( $meta_ids, $arg2, $arg3, $arg4 ) {
// Your code runs here.
}, 10, 4 );Argument names come from Yoast SEO's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
9 plugins that fire delete_post_meta
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
Yoast SEO10+ million installs
do_action( 'delete_post_meta', $meta_ids, null, null, null )inc/class-wpseo-meta.php:909 -
Image Watermark40,000+ installs
do_action( 'delete_post_meta', $ids, $id, $key, '' )includes/class-upload-handler.php:11552 -
SOOZ2,000+ installs
do_action( 'delete_post_meta', $meta_ids, $attachment_post_id, $meta_key, $rollback_hook_value )includes/core/attachments-media.php:3168 -
Faire for WooCommerce800+ installs
do_action( 'delete_post_meta', $surplus, $id, self::META_FAIRE_PRODUCT_SYNC_RESULT, '' )src/sync/class-sync-product.php:1933 -
ProRank SEO10+ installs
do_action( 'delete_post_meta', $ids, $id, $key, $expected )includes/Core/Content/PostContentWriter.php:114 -
Altify AI10+ installs
do_action( 'delete_post_meta', array($meta_id), $id, self::ALT_KEY, $expected['value'] )includes/class-altify-ai-review.php:79 -
PerfLocaleFewer than 10 installs
do_action( 'delete_post_meta', [ $id ], $post_id, $key, '' )src/Translation/Fields/PostMetaStorage.php:181 -
Baza Booking CalendarFewer than 10 installs
do_action( 'delete_post_meta', $meta_ids, $post_id, $meta_key, $meta_value )classes/class-bbc-booking-meta.php:445 -
JonnyAD SEOFewer than 10 installs
do_action( 'delete_post_meta', array($meta_id), $post_id, $key, $from )includes/admin.php:1435
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.