Hey! Sorry I missed this! I actually have things set up to automatically create a post with each image that is uploaded via functions.php. So a submit button works to refresh the page, but the images that were loaded, already have created posts on initial upload.
What would be even better is if this action only applied to images uploaded by your plugin and not anywhere else.
Here is the code in my functions:
add_action('add_attachment', 'create_post');
function create_post( $attach_ID ) {
$attachment = get_post( $attach_ID );
$my_post_data = array(
'post_title' => $attachment->post_title,
'post_type' => 'product',
'post_category' => array('0'),
'post_status' => 'draft',
);
$post_id = wp_insert_post( $my_post_data );
// attach media to post
wp_update_post( array(
'ID' => $attach_ID,
'post_parent' => $post_id,
) );
set_post_thumbnail( $post_id, $attach_ID );
return $attach_ID;
}
1) Is it possible to have this action only occur with your plugin uploads
2) Where would I adjust the hidden input that you referred to earlier?
Thanks for any insight you have and sorry for the late reply!
Kylie