WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/set post thumbnail

Contents

Description

Sets a post thumbnail.

Usage

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

Parameters

$post
(int) (Post ID or object where thumbnail should be attached.) object
Default: required
$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.