• 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?

    Thanks!
    Christiann

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Christiann

    (@xiann)

    That was pretty easy! I figured it out:

    add_post_meta( $post_id, '_thumbnail_id', $attach_id );

    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.

    set_post_thumbnail($post_id, $attachment_id);

    The function will return true or false depending on weather it was successful or not.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to set post thumbnail in my plugin’ is closed to new replies.