PHP/Manual use of images? – 2 Questions

Function Reference/wp insert attachment

$image_id = wp_insert_attachment( $attachment, $filename, $parent_post_id );

This function will return an image id which you can use for the featured image.

update_post_meta($post_id, "_thumbnail_id", $image_id);

Leave a Comment