I'm currently working on a project where we are using Wordpress 3.0 RC. The idea is to create custom post types with meta boxes to make the system easier to use for the client. Some of these posts need to have multiple files attached to them, and by attached I do not mean inserted to post but rather we'd like to keep them separate from the post body (in fact, a given post type might not even have text, only files).
I'm wondering if there is a standard approach for allowing multiple files to be attached to a Wordpress post? I've managed to add a meta box that allows one file from the media library to be selected, but I have no idea how to extend this to allow an arbitra开发者_如何转开发ry number of files. Hope someone can help!
When a user is writing a post, and proceeds to upload media, that media is automatically 'attached' to the current post.
However, unless the user chooses to 'insert gallery', the media will not appear within the post, but it is still associated with the post.
You can get all media for a post using get_children()
like so;
$media = get_children(array(
'post_parent' => $post_ID,
'post_type' => 'attachment'
));
精彩评论