I’m working on a plugin that implements a custom post type, and it doesn’t need the editor, but I do want to upload files. I setup the everything like you normally would, but I noticed that the files weren’t being attached to the post when they were uploaded.
I couldn’t find anything online, so I dug through the uploader source and traced it back to the fact that I wasn’t passing the post ID to wp_enqueue_media().
1 2 | wp_enqueue_media(); // files will not be attached to anything wp_enqueue_media( array ( 'post' => $post ->ID ) ); // files will be attached to $post |