WordPress.org

Ready to get started?Download WordPress

Forums

Best practices for adding attachments to custom post types (4 posts)

  1. sublink
    Member
    Posted 4 years ago #

    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?

    Thanks!

  2. sublink
    Member
    Posted 4 years ago #

    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.

    Thanks!

  3. scorpion380
    Member
    Posted 4 years ago #

    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

  4. brightidea
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic