Filter hook 'post_thumbnail_id'

in WP Core File wp-includes/post-thumbnail-template.php at line 70

View Source

post_thumbnail_id

Filter Hook
Description
Filters the post thumbnail ID.

Hook Information

File Location wp-includes/post-thumbnail-template.php View on GitHub
Hook Type Filter
Line Number 70

Hook Parameters

Type Name Description
int|false $thumbnail_id Post thumbnail ID or false if the post does not exist.
int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`.

Usage Examples

Basic Usage
<?php
// Hook into post_thumbnail_id
add_filter('post_thumbnail_id', 'my_custom_filter', 10, 2);

function my_custom_filter($thumbnail_id, $post) {
    // Your custom filtering logic here
    return $thumbnail_id;
}

Source Code Context

wp-includes/post-thumbnail-template.php:70 - How this hook is used in WordPress core
<?php
  65  	 * @since 5.9.0
  66  	 *
  67  	 * @param int|false        $thumbnail_id Post thumbnail ID or false if the post does not exist.
  68  	 * @param int|WP_Post|null $post         Post ID or WP_Post object. Default is global `$post`.
  69  	 */
  70  	return (int) apply_filters( 'post_thumbnail_id', $thumbnail_id, $post );
  71  }
  72  
  73  /**
  74   * Displays the post thumbnail.
  75   *

PHP Documentation

<?php
/**
	 * Filters the post thumbnail ID.
	 *
	 * @since 5.9.0
	 *
	 * @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. Default is global `$post`.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/post-thumbnail-template.php
Related Hooks

Related hooks will be displayed here in future updates.