Core Function
View Source on Trac ↗ set_post_thumbnail()
set_post_thumbnail( mixed $post, mixed $thumbnail_id ) Sets the post thumbnail (featured image) for the given post.
Parameters 2 required
| Name / Type | Description |
|---|---|
| (int | | WP_Post) $post Post ID or post object where thumbnail should be attached. Required |
| $thumbnail_id int | Thumbnail to attach. Required |
Return Value
((int)
(int | bool) Post meta ID if the key didn't exist (ie. this is the first time that
a thumbnail has been saved for the post), true on successful update,
false on failure or if the value passed is the same as the one that
is already in the database.
Function Information
Since Version
3.1.0
Source File
wp-includes/post.php
Advertisement