Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The question is "How do I add one or more fields to the Category, Tag and Custom Taxonomy Edit Screen in the WordPress Admin?" This question was asked on the wp-hackers list August 1st 2010 and I offered a solution later that day. The original asker discussed the issue again today (Aug 21) which reminded me of the solution. Since it could be a common need I decided to post the solution including code up here for others to find in the future.

share|improve this question
    
Hi mike, I think it would be better if you post the code in answer box. That way, we have backup here, in case github down. –  ariefbayu Aug 22 '10 at 8:13
    
@silent: Hey, I'm working on it. :) I'm halfway done, but I've hit a wall and need to sleep. Here's what it'll look (something) like when I'm done: wordpress.stackexchange.com/questions/578/#582 –  MikeSchinkel Aug 22 '10 at 8:28
    
You'll make it :D - I'm pretty sure. –  hakre Aug 27 '10 at 22:20
    
Any more developments on this one? I'm actually kind of interested... :D –  John P Bloch Sep 27 '10 at 21:19
    
Hey @John P Bloch: My clients have pinned me down and just haven't had time. Hopefully soon... –  MikeSchinkel Sep 28 '10 at 7:14
show 4 more comments

5 Answers

I added new field 'picture' (input type file) to category with help of these

add_action('category_edit_form_fields','category_edit_form_fields');
add_action('category_edit_form', 'category_edit_form');
add_action('category_add_form_fields','category_edit_form_fields');
add_action('category_add_form','category_edit_form');


function category_edit_form() {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#edittag').attr( "enctype", "multipart/form-data" ).attr( "encoding", "multipart/form-data" );
        });
</script>
<?php 
}

function category_edit_form_fields () {
?>
    <tr class="form-field">
            <th valign="top" scope="row">
                <label for="catpic"><?php _e('Picture of the category', ''); ?></label>
            </th>
            <td>
                <input type="file" id="catpic" name="catpic"/>
            </td>
        </tr>
        <?php 
    }

You are free to use any taxonomy, just replace category to your taxonomy name

share|improve this answer
    
this is excellent but could you please explain (or provide an example possibly) how one would correctly integrate this customization if you want to add this to a custom taxonomy - for example "people" –  NetConstructor.com Jan 19 '11 at 11:48
1  
Update - Although I have copied your exact code above to test this the file does not seem to be saved or at least it is not showing up. Could you explain where its saving the file, maybe the permissions of that folder need to be edited (or even better, could you possibly describe how one would go about modifying the location of the folder where its saved?). When I select a file and then try to save a term its saving everything except for the file and thus does not show me the image uploaded. –  NetConstructor.com Jan 19 '11 at 11:56
    
@tpoxa : great answer. How to save the image –  gowri Jun 12 '12 at 18:08
add comment

You need to add your code in to your themes functions.php file - also if you want to add that field into the custom taxonomy form you just substitute category with the custom taxonomy name in the add_action function. Example : add_action('category_edit_form_fields','category_edit_form_fields'); will be add_action('custom_taxonomy_name_form_fields','function_name_to_hook_on');

share|improve this answer
add comment

...also if you want to add that field into the custom taxonomy form you just substitute category with the custom taxonomy name in the add_action function. Example:

add_action('{custom_taxonomy}_edit_form_fields','category_edit_form_fields'); add_action('{custom_taxonomy}_edit_form', 'category_edit_form'); add_action('{custom_taxonomy}_add_form_fields','category_edit_form_fields'); add_action('{custom_taxonomy}_add_form','category_edit_form');

share|improve this answer
add comment

I use the Category Meta PLugin. Works on all custom taxonomy's, tags & categorys

share|improve this answer
add comment

For those looking to hook into the tag form field, the hook is slightly different.

add_tag_form_fields

instead of tag_add_form_fields as you would expect

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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