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.
Leave a Reply
You must be logged in to post a comment.
I added new field ‘picture’ (input type file) to category with help of these
You are free to use any taxonomy, just replace
category
to your taxonomy nameAlso, 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:
I have Added the add image and Remove image extra filed into custom taxonomy which name is insurance.
Note: If you wanted to add this field to a different taxonomy, e.g. for a custom post type, youâd need to replace the reference to category with a reference to your own taxonomy slug. For example, if you add created a genre taxonomy you would hook this function via
My taxonomy slug name is insurance.
add_action( ‘insurance_add_form_fields’, array ( $this, ‘add_category_image’ ), 10, 2 );
Use this code in your
functions.php
file.For those looking to hook into the tag form field, the hook is slightly different.
instead of tag_add_form_fields as you would expect
I realize this was asked a while ago, but WordPress has changed a bit since so I decided to develop a small script that simplifies the process of adding custom fields to taxonomies, and optionally lets you add columns to the terms table for each field. The script is called amarkal-taxonomy, and is part of the Amarkal WordPress framework.
Using
amarkal-taxonomy
, adding a custom field simplifies to: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’);
I use the Category Meta PLugin. Works on all custom taxonomy’s, tags & categorys