Title: Taxonomyextra fields?
Last modified: August 21, 2016

---

# Taxonomyextra fields?

 *  [My](https://wordpress.org/support/users/midorian/)
 * (@midorian)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/taxonomyextra-fields/)
 * I found this code that I can add to the functions file to have extra fields for
   categories to show up in admin.
 *     ```
       //add extra fields to category edit form hook
       add_action ( 'edit_category_form_fields', 'extra_category_fields');
       //add extra fields to category edit form callback function
       function extra_category_fields( $tag ) {    //check for existing featured ID
           $t_id = $tag->term_id;
           $cat_meta = get_option( "category_$t_id");
       ?>
       <tr class="form-field">
       <th scope="row" valign="top"><label for="cat_Image_url"><?php _e('Category Image Url'); ?></label></th>
       <td>
       <input type="text" name="Cat_meta[img]" id="Cat_meta[img]" size="3" style="width:60%;" value="<?php echo $cat_meta['img'] ? $cat_meta['img'] : ''; ?>"><br />
                   <span class="description"><?php _e('Image for category: use full url with http://'); ?></span>
               </td>
       </tr>
       <tr class="form-field">
       <th scope="row" valign="top"><label for="extra1"><?php _e('extra field'); ?></label></th>
       <td>
       <input type="text" name="Cat_meta[extra1]" id="Cat_meta[extra1]" size="25" style="width:60%;" value="<?php echo $cat_meta['extra1'] ? $cat_meta['extra1'] : ''; ?>"><br />
                   <span class="description"><?php _e('extra field'); ?></span>
               </td>
       </tr>
       <tr class="form-field">
       <th scope="row" valign="top"><label for="extra2"><?php _e('extra field'); ?></label></th>
       <td>
       <input type="text" name="Cat_meta[extra2]" id="Cat_meta[extra2]" size="25" style="width:60%;" value="<?php echo $cat_meta['extra2'] ? $cat_meta['extra2'] : ''; ?>"><br />
                   <span class="description"><?php _e('extra field'); ?></span>
               </td>
       </tr>
       <tr class="form-field">
       <th scope="row" valign="top"><label for="extra3"><?php _e('extra field'); ?></label></th>
       <td>
                   <textarea name="Cat_meta[extra3]" id="Cat_meta[extra3]" style="width:60%;"><?php echo $cat_meta['extra3'] ? $cat_meta['extra3'] : ''; ?></textarea><br />
                   <span class="description"><?php _e('extra field'); ?></span>
               </td>
       </tr>
       <?php
       }
       ```
   
 * However, I would like the extra fields to appear in a new post type/Taxonomy 
   that I created – how do I do that?
 * Other questions:
 * – Is it possible to have one of the extra fields to be a file upload?
    – How 
   do I call the extra fields in my theme so they show up in the front end?
 * Thanks <3

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/taxonomyextra-fields/#post-4989999)
 * Use `register_taxonomy_for_object_type()` to associate the category taxonomy 
   with your new post type. The category meta box will then show up on the edit 
   page, along with the additional custom fields.
 * You can add a file upload field, but you also need to process the file when the
   form is submitted. Use `wp_handle_upload()` to attach the file to the custom 
   post, or use `media_handle_sideload()` to simply upload without attaching it.
 * To display the category metabox elsewhere, first you need the taxonomy object
   from `get_taxonomy()`. The meta box callback will then be `$taxonomy->meta_box_cb`.
   The normal process of adding meta boxes then calling `do_meta_boxes()` only works
   for the back end AFAIK, but you can use the callback to display the box, but 
   you’ll have to handle the form submit yourself.

Viewing 1 replies (of 1 total)

The topic ‘Taxonomyextra fields?’ is closed to new replies.

## Tags

 * [extra fields](https://wordpress.org/support/topic-tag/extra-fields/)
 * [post-type](https://wordpress.org/support/topic-tag/post-type/)
 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/taxonomyextra-fields/#post-4989999)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
