Action hook 'delete_postmeta'

in WP Core File wp-includes/meta.php at line 496

View Source

delete_postmeta

Action Hook
Description
Fires immediately before deleting metadata for a post.

Hook Information

File Location wp-includes/meta.php View on GitHub
Hook Type Action
Line Number 496

Hook Parameters

Type Name Description
string[] $meta_ids An array of metadata entry IDs to delete.

Usage Examples

Basic Usage
<?php
// Hook into delete_postmeta
add_action('delete_postmeta', 'my_custom_function', 10, 1);

function my_custom_function($meta_ids) {
    // Your custom code here
}

Source Code Context

wp-includes/meta.php:496 - How this hook is used in WordPress core
<?php
 491  		 *
 492  		 * @since 2.9.0
 493  		 *
 494  		 * @param string[] $meta_ids An array of metadata entry IDs to delete.
 495  		 */
 496  		do_action( 'delete_postmeta', $meta_ids );
 497  	}
 498  
 499  	$query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . ' )';
 500  
 501  	$count = $wpdb->query( $query );

PHP Documentation

<?php
/**
		 * Fires immediately before deleting metadata for a post.
		 *
		 * @since 2.9.0
		 *
		 * @param string[] $meta_ids An array of metadata entry IDs to delete.
		 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/meta.php
Related Hooks

Related hooks will be displayed here in future updates.