views:

22

answers:

1

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 arbitrary number of files. Hope someone can help!

A: 

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'
));
TheDeadMedic
That's very useful, however what I'd like to be able to do is add existing files from the media library and not have to upload them again. I found a plugin called Attachments which works decently though, so no panic :)
erik.brannstrom