Support » Plugins and Hacks » Hacks » How to set post thumbnail in my plugin
5 years, 11 months ago
I’m making a plugin that uses wp_insert_post() and wp_update_post() to create and edit posts, but I’m not clear on how to set an thumbnail image in my code.
I’m looking for something like wp_set_post_thumbnail_image($post_ID, $attachment_ID) but of course, that’s not quite right.
Does anyone know how I can do this?
That was pretty easy! I figured it out:
add_post_meta( $post_id, '_thumbnail_id', $attach_id );
5 years, 6 months ago
Hi, i know you you figured it out but in wp 3.1 there is a new function called set_post_thumbnail(); The page is appears to be still blank 🙂 But here how you can use it.
The function will return true or false depending on weather it was successful or not.