delete_post_thumbnail() WordPress Function

The delete_post_thumbnail() function allows you to delete a post thumbnail. This function takes a single argument, which is the post ID of the post you want to delete the thumbnail from. This function does not return a value.

delete_post_thumbnail( int|WP_Post $post ) #

Removes the thumbnail (featured image) from the given post.


Parameters

$post

(int|WP_Post)(Required)Post ID or post object from which the thumbnail should be removed.


Top ↑

Return

(bool) True on success, false on failure.


Top ↑

Source

File: wp-includes/post.php

function delete_post_thumbnail( $post ) {
	$post = get_post( $post );
	if ( $post ) {
		return delete_post_meta( $post->ID, '_thumbnail_id' );
	}
	return false;
}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More