has_post_thumbnail
Filters whether a post has a post thumbnail.
Usage
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.
Default: global $post - $thumbnail_id(int|false)
- Post thumbnail ID or false if the post does not exist.
Changelog
Since 5.1.0 | Introduced. |
Where the hook is called
has_post_thumbnail
wp-includes/post-thumbnail-template.php 38
return (bool) apply_filters( 'has_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );