Support » Plugins » Best practices for adding attachments to custom post types

  • Hi there,

    I’m working on a simple document plugin for a client, using the new Custom Post Types in WordPress 3.

    We’d like to have just the title and an upload field. So, I’m setting:

    register_post_type('post_type_name', array('supports' => array('title'), ...)

    to only have the title show up. Now, what’s the best way to add an upload field?

    I started by adding a meta box using add_meta_box, and having a simple input type="file" there. But the post form does not have the enctype set. I found a bug report, but the developers mention that it is better to handle the uploads asynchronously. Are there any resources available that discuss this?


Viewing 3 replies - 1 through 3 (of 3 total)
  • sublink


    So, it looks like there’s no standard way to add a file input to the post page.

    I’ve seen several plugins handle their own uploads—could anyone point me to some tutorials on doing this? Particularly how to handle the upload on the PHP side.




    I read somewhere that you can upload the file using image uploader or mediae uploader built into the post. However, I am looking to know how I can then display a drop down box in my custom post using custom fields which lists all the attachments for each post.

    good luck

    Im also looking to accomplish this. I have tried every tutorial i can find and even tried modifying existing plugins just to attach a pdf document. I can easily allow them to paste in links but they are pretty demanding clients so i’d really like to make it as easy as possible.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Best practices for adding attachments to custom post types’ is closed to new replies.