Attach the image to a post on upload
-
Hi im using wpcf7_before_send_mail to create a draft post when submitting a contact form 7 entry. Im using this plugin to save the image file used in the cf7 entry which uploads it to the media library fine.
however im sturggling to find a way of then grabbing that image from the media library and setting it as a featured image for that post?
my data looks like this
`$my_post = array(
‘post_title’ => $posted_data[‘testimonial-title’],
‘post_content’ => $posted_data[‘testimonial-content’],
‘post_status’ => ‘publish’,
‘post_type’ => ‘living’,
);wp_insert_post($my_post);
is there a filter what i can use to give me the id of the image so i can attach it like this?
set_post_thumbnail( $post_id, IMAGE ID TO GO HERE);
- The topic ‘Attach the image to a post on upload’ is closed to new replies.