WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/set post thumbnail

Description

Sets a post thumbnail.

Usage

<?php set_post_thumbnail$post$thumbnail_id ); ?>

Parameters

$post
(int/object) (required) Post ID or object where thumbnail should be attached.
Default: None
$thumbnail_id
(integer) (required) Thumbnail to attach.
Default: None

Return Values

(int/bool) 
Post meta ID on success, false on failure.

Change Log

Source File

set_post_thumbnail() is located in wp-includes/post.php.

Related

delete_post_thumbnail()

See also index of Function Reference and index of Template Tags.