wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema
set_post_thumbnail › WordPress Function
Desde3.1.0
Obsoleton/a
› set_post_thumbnail ( $post, $thumbnail_id )
| Parâmetros: (2) |
|
| Retorna: |
|
| Definido em: |
|
| Codex: |
Sets the post thumbnail (featured image) for the given post.
Funções relacionadas: has_post_thumbnail, the_post_thumbnail, set_post_thumbnail_size, delete_post_thumbnail, get_post_thumbnail_id
Fonte
function set_post_thumbnail( $post, $thumbnail_id ) {
$post = get_post( $post );
$thumbnail_id = absint( $thumbnail_id );
if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
if ( wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) {
return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
} else {
return delete_post_meta( $post->ID, '_thumbnail_id' );
}
}
return false;
}