post_thumbnail_id
Filters the post thumbnail ID.
Использование
add_filter( 'post_thumbnail_id', 'wp_kama_post_thumbnail_id_filter', 10, 2 );
/**
* Function for `post_thumbnail_id` filter-hook.
*
* @param int|false $thumbnail_id Post thumbnail ID or false if the post does not exist.
* @param int|WP_Post|null $post Post ID or WP_Post object.
*
* @return int|false
*/
function wp_kama_post_thumbnail_id_filter( $thumbnail_id, $post ){
// filter...
return $thumbnail_id;
}
- $thumbnail_id(int|false)
- Post thumbnail ID or false if the post does not exist.
- $post(int|WP_Post|null)
- Post ID or WP_Post object.
По умолчанию: global$post
Список изменений
| С версии 5.9.0 | Введена. |
Где вызывается хук
post_thumbnail_id
wp-includes/post-thumbnail-template.php 70
return (int) apply_filters( 'post_thumbnail_id', $thumbnail_id, $post );