On this page
delete_post_thumbnail( int|WP_Post $post ): bool
Removes the thumbnail (featured image) from the given post.
Parameters
$postint|WP_Post Required-
Post ID or post object from which the thumbnail should be removed.
Return
bool True on success, false on failure.
Source
File: wp-includes/post.php. View all references
function delete_post_thumbnail( $post ) {
$post = get_post( $post );
if ( $post ) {
return delete_post_meta( $post->ID, '_thumbnail_id' );
}
return false;
}
Related
Uses
| Uses | Description |
|---|---|
| delete_post_meta() wp-includes/post.php | Deletes a post meta field for the given post ID. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Posts_Controller::handle_featured_media() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Determines the featured media based on a request param. |
| wp_ajax_set_post_thumbnail() wp-admin/includes/ajax-actions.php | Ajax handler for setting the featured image. |
| wp_insert_post() wp-includes/post.php | Inserts or update a post. |
| wp_xmlrpc_server::mw_editPost() wp-includes/class-wp-xmlrpc-server.php | Edit a post. |
| wp_xmlrpc_server::_insert_post() wp-includes/class-wp-xmlrpc-server.php | Helper method for wp_newPost() and wp_editPost(), containing shared logic. |
Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/delete_post_thumbnail