2
votes

I am creating a custom post type music.

function layzend_admin_music_init() {
  add_meta_box("layzend_music_information-meta", "Information", "layzend_music_information", "music", "normal", "low");
}

function layzend_music_information() {
    ?>
    <p>
        <label for="layzend_music_url">URL</label>
        <input type="file" id="layzend_music_url" name="layzend_music_url" />
    </p>
    <?php
}

This file field needs the form enctype to be multipart/form data how can I change the default form enctype for a custom post type?

1

1 Answers

8
votes

Try this:

add_action('post_edit_form_tag', 'add_post_enctype');

function add_post_enctype() {
    echo ' enctype="multipart/form-data"';
}

More info in the Codex.

Does that work for you?