Definition:
function set_post_thumbnail( $post, $thumbnail_id ) {}
Sets a post thumbnail.
Parameters
- int|object $post: Post ID or object where thumbnail should be attached.
- int $thumbnail_id: Thumbnail to attach.
Return values
returns:True on success, false on failure.
Source code
function set_post_thumbnail( $post, $thumbnail_id ) { $post = get_post( $post ); $thumbnail_id = absint( $thumbnail_id ); if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) { $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ); if ( ! empty( $thumbnail_html ) ) { update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id ); return true; } } return false; }
10273
No comments yet... Be the first to leave a reply!