has_post_thumbnail
Filter HookDescription
Filters whether a post has a post thumbnail.Hook Information
File Location |
wp-includes/post-thumbnail-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 38 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$has_thumbnail
|
true if the post has a post thumbnail, otherwise false. |
int|WP_Post|null
|
$post
|
Post ID or WP_Post object. Default is global `$post`. |
int|false
|
$thumbnail_id
|
Post thumbnail ID or false if the post does not exist. |
Usage Examples
Basic Usage
<?php
// Hook into has_post_thumbnail
add_filter('has_post_thumbnail', 'my_custom_filter', 10, 3);
function my_custom_filter($has_thumbnail, $post, $thumbnail_id) {
// Your custom filtering logic here
return $has_thumbnail;
}
Source Code Context
wp-includes/post-thumbnail-template.php:38
- How this hook is used in WordPress core
<?php
33 *
34 * @param bool $has_thumbnail true if the post has a post thumbnail, otherwise false.
35 * @param int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`.
36 * @param int|false $thumbnail_id Post thumbnail ID or false if the post does not exist.
37 */
38 return (bool) apply_filters( 'has_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );
39 }
40
41 /**
42 * Retrieves the post thumbnail ID.
43 *
PHP Documentation
<?php
/**
* Filters whether a post has a post thumbnail.
*
* @since 5.1.0
*
* @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. Default is global `$post`.
* @param int|false $thumbnail_id Post thumbnail ID or false if the post does not exist.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/post-thumbnail-template.php
Related Hooks
Related hooks will be displayed here in future updates.