[wp-hackers] Set post thumbnail via code

Glenn Ansley glenn at glennansley.com
Fri Mar 12 15:41:30 UTC 2010


Do you need something more than this:
update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id );

I got that from /wp-admin/admin-ajax.php L1413 on trunk (several revisions
back though).

Glenn Ansley
http://fullthrottledevelopment.com
http://twitter.com/glennansley

On Fri, Mar 12, 2010 at 10:31 AM, Brad Williams <bradw at illiams.com> wrote:

> Is it possible to set a post thumbnail using code?  I've been digging
> through the Core process of setting a post thumbnail and it appears the
> WPSetAsThumbnail() function (located in set-post-thumbnail.js) is what
> actually creates/assigns the thumbnail, but I wasn't sure if this could be
> called directly?
>
>
>
> Has anyone tried this?
>
>
>
> -Brad
>
> @williamsba
>
>
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list