default_post_metadata
Filters the default metadata value for a specified meta key and object.
Possible filter names include:
This is one of the variants of the dynamic hook default_(meta_type)_metadata
Usage
add_filter( 'default_post_metadata', 'wp_kama_default_post_metadata_filter', 10, 5 ); /** * Function for `default_post_metadata` filter-hook. * * @param mixed $value The value to return, either a single metadata value or an array of values depending on the value of `$single`. * @param int $object_id ID of the object metadata is for. * @param string $meta_key Metadata key. * @param bool $single Whether to return only the first value of the specified `$meta_key`. * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table. * * @return mixed */ function wp_kama_default_post_metadata_filter( $value, $object_id, $meta_key, $single, $meta_type ){ // filter... return $value; }
- $value(mixed)
- The value to return, either a single metadata value or an array of values depending on the value of $single.
- $object_id(int)
- ID of the object metadata is for.
- $meta_key(string)
- Metadata key.
- $single(true|false)
- Whether to return only the first value of the specified $meta_key.
- $meta_type(string)
- Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.
Changelog
Since 5.5.0 | Introduced. |
Where the hook is called
default_post_metadata
wp-includes/meta.php 717
$value = apply_filters( "default_{$meta_type}_metadata", $value, $object_id, $meta_key, $single, $meta_type );