Custom post types and file upload taxonomies
-
Hi,
I’ve created a custom post type, called “PDF”.
I’ve configured it so only a title and thumbnail are accepted.
I then added a custom taxonomy, for the PDF file, and added a <input type=”file”> to the Add New Window.It looks like it works. But, when a PDF is added, the post is created, but the PDF is not saved.
Here is my code:
function pdfa() { $labels = array( 'name' => _x('PDFs', 'post type general name'), 'singular_name' => _x('PDF', 'post type singular name'), 'add_new' => _x('Add PDF', 'sports article'), 'add_new_item' => __('Add PDF'), 'edit_item' => __('Edit PDF'), 'new_item' => __('Create PDF'), 'view_item' => __('View PDF'), 'search_items' => __('Search PDF'), 'not_found' => __('No PDFs found'), 'not_found_in_trash' => __('No PDFs found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => 20, 'supports' => array('title', 'thumbnail') ); register_post_type('pdfa',$args); }
function admin_init() { add_meta_box("pdfMeta", "Attach PDF", "meta_options", "pdfa", "normal", "high"); } function meta_options() { global $post; $custom = get_post_custom($post->ID); $pdf = $custom["pdf_file"][0]; ?> <label>PDF:</label><input type="file" name="pdf_file" value="<?php echo $pdf; ?>" /> <?php } function save_pdf() { global $post; update_post_meta($post->ID, "pdfa", $_POST["pdf_file"]); }
Thanks for the help.
Jeff
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom post types and file upload taxonomies’ is closed to new replies.