I'm trying to associate an existing image from the media library with a post (It's a custom post type), If I use
wp_insert_attachment I get a duplicate in the media library, so I'm getting the image
id and using that as the
$attach_id = intval( $file['id'] ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); $result = wp_update_attachment_metadata( $attach_id, $attach_data );
This doesn't work and the
$result is false.
I'm sure I'm missing something simple. Can anybody enlighten me?