0

I need to add one image uploading field to my custom post type. But it should be inside the taxonomy (product category). How can i add that field?.

<?php
add_action('init', 'wlg_cstm_register');  

 function wlg_cstm_register() {  

    $product_labels = array(
    'name' => _x('Products', 'post type general name'),
    'singular_name' => _x('Product', 'post type singular name'),
    'add_new' => _x('Add New', 'Product'),
    'add_new_item' => __('Add New Product'),
    'edit_item' => __('Edit Product'),
    'new_item' => __('New Product'),
    'view_item' => __('View Products'),
    'search_items' => __('Search Products'),
    'not_found' =>  __('No Products found'),
    'not_found_in_trash' => __('No Products found in Trash'), 
    'parent_item_colon' => ''
);

    $product_args = array(  
         'labels' => $product_labels,  
         'public' => true,  
         'show_ui' => true,  
         'capability_type' => 'post',  
         'hierarchical' => false,  
         'rewrite' => true,
         'supports' => array('title', 'editor', 'thumbnail'),
        'taxonomies' => array( '' ),
        'menu_icon' => get_bloginfo('template_directory') . '/resources/img/Products-icon.png',  // Icon Path
        'has_archive' => false       
        );

     register_post_type( 'products' , $product_args ); 
     register_taxonomy( 'item', 'products', array( 'hierarchical' => true, 'label' => __('Product Category'), 'query_var' => 'item' ) );
 }
  • Please always add your code to your question. Do not link to outside sources for relevant parts of a question. – kaiser Aug 2 '14 at 0:39
1

There is a plugin for that http://wordpress.org/extend/plugins/taxonomy-metadata/

OR

Adding custom meta fields to a taxonomy requires three separate functions: one to add the field to the Add New page; one to add the field to the Edit Term page; and one to save the values of the custom field from both pages.

You can also do this by code yourself like this :

https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.