WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Seem to be having a few issues with this project lately so sorry for spamming questions! I needed to give the category edit page in the admin a few additional fields to allow my client to manage them better.

The extra fields I added are 'Category Features' and 'Category Applications' and the following code seems to be working as expected:

// Add custom fields to category edit pages
// the option name
define('Category_Extras', 'Category_Extras_option');

// your fields (the form)
add_filter('edit_category_form', 'Category_Extras');
function Category_Extras($tag) {
    $tag_extra_fields = get_option(Category_Extras);


<table class="form-table">
        <tr class="form-field">
            <th scope="row" valign="top"><label for="Category_Extras_Features">Category Features</label></th>
            <td><textarea style="width: 97%;" cols="50" rows="5" name="Category_Extras_Features" id="Category_Extras_Features" class="tinymce"><?php  echo $tag_extra_fields[$tag->term_id]['Category_Extras_Features']; ?></textarea>
            <p class="description">This isn't applicable to all categories but allows additional information to be displayed on a category page.</p></td>
        <tr class="form-field">
            <th scope="row" valign="top"><label for="Category_Extras_Applications">Category Applications</label></th>
            <td><textarea style="width: 97%;" cols="50" rows="5" name="Category_Extras_Applications" id="Category_Extras_Applications" class="Category_Extras_Features"><?php  echo $tag_extra_fields[$tag->term_id]['Category_Extras_Applications']; ?></textarea>
            <p class="description">This isn't applicable to all categories but allows additional information to be displayed on a category page.</p></td>


// when the form gets submitted, and the category gets updated (in your case the option will get updated with the values of your custom fields above
add_filter('edited_terms', 'update_Category_Extras');
function update_Category_Extras($term_id) {
  if($_POST['taxonomy'] == 'category'):
    $tag_extra_fields = get_option(Category_Extras);
    $tag_extra_fields[$term_id]['Category_Extras_Features'] = strip_tags($_POST['Category_Extras_Features']);
    $tag_extra_fields[$term_id]['Category_Extras_Applications'] = strip_tags($_POST['Category_Extras_Applications']);
    update_option(Category_Extras, $tag_extra_fields);

// when a category is removed
add_filter('deleted_term_taxonomy', 'remove_Category_Extras');
function remove_Category_Extras($term_id) {
  if($_POST['taxonomy'] == 'category'):
    $tag_extra_fields = get_option(Category_Extras);
    update_option(Category_Extras, $tag_extra_fields);

I'm echo'ing this out on the page as follows:

<?php $prod_features = get_option(Category_Extras); foreach($prod_features as $feature) { echo $feature['Category_Extras_Features']; } ?>

However, obviously its echoing out all the options for all the categories. Is there a different finction which would allow me to echo out the 'Category Features' for the current category? (this code is being displayed on the category.php page)

As always I'd really appreciate your help :-)



share|improve this question
up vote 0 down vote accepted

Sorted this myself! May help some people...

$cat = get_query_var('cat');
$prod_extras = get_option(Category_Extras);
$this_application = $prod_extras[$cat]['Category_Extras_Applications'];

if(!empty($this_application)) { echo $this_application; }



share|improve this answer
Tip: It's a good idea to check array keys exist before you reference them in a variable(isset is a cheap way to check), else you'll produce PHP notices(though you'll likely not notice them without error reporting on). – t31os Mar 8 '11 at 13:31
@t31os thanks for the tip! i'll make sure I do that :-) – daveaspinall Mar 8 '11 at 13:54
how to do it for custom taxonomy? – Krunal Dec 31 '12 at 12:17

For category custom fields there is this plug in : http://wordpress.org/extend/plugins/categorycustomfields/

share|improve this answer

Your Answer


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.