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