Function: set_post_thumbnail

set_post_thumbnail( integer | WP_Post $post, integer $thumbnail_id )

Set a post thumbnail.


Name Type(s) Default Value Description
$post integer | WP_Post

Post ID or post object where thumbnail should be attached.

$thumbnail_id integer

Thumbnail to attach.


integer | boolean

True on success, false on failure.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.