delete_post_thumbnail()
Deletes the post thumbnail by post ID. The meta-field is deleted, not the thumbnail file itself.
Use wp_delete_attachment() to delete the file physically.
No Hooks.
Returns
true|false. Boolean true or false.
Usage
delete_post_thumbnail( $post );
- $post(int/object) (required)
- The post ID whose thumbnail should be deleted. You may pass a post object.
Examples
#1 Remove the thumbnail of the posts
delete_post_thumbnail( 56 );
This function is analogous to such a string:
delete_post_meta( 56, '_thumbnail_id' );
Changelog
| Since 3.3.0 | Introduced. |
delete_post_thumbnail() delete post thumbnail code WP 6.8.3
function delete_post_thumbnail( $post ) {
$post = get_post( $post );
if ( $post ) {
return delete_post_meta( $post->ID, '_thumbnail_id' );
}
return false;
}