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.

So I'm able to add an extra field to my categories (A Color picker actually, to color code categories - pretty cool stuff if anybody is interested) but the extra field ONLY shows up under Posts. I have a CPT with its own category page and it doesn't show up there. Is there a way to only have the extra field show up under my CPT categories page? Do I need to hook into something different?

Here's what I'm doing now:

/** Add New Field To Category **/
function extra_category_fields( $tag ) {
    $t_id = $tag->term_id;
    $cat_meta = get_option( "category_$t_id" );
?>
<tr class="form-field">
    <th scope="row" valign="top"><label for="meta-color"><?php _e('Category Name Background Color'); ?></label></th>
    <td>
        <div id="colorpicker">
            <input type="text" name="cat_meta[catBG]" class="colorpicker" size="3" style="width:20%;" value="<?php echo (isset($cat_meta['catBG'])) ? $cat_meta['catBG'] : '#fff'; ?>" />
        </div>
            <br />
        <span class="description"><?php _e(''); ?></span>
            <br />
        </td>
</tr>
<?php
}
add_action ( 'category_add_form_fields', 'extra_category_fields');
add_action('category_edit_form_fields','extra_category_fields');
share|improve this question
    
Have you created custom taxonomy for CPT? –  Vinod Dalvi Sep 5 '13 at 14:46

1 Answer 1

up vote 1 down vote accepted

You can add the following hooks in your code to add it to event-category custom taxonomy.

add_action('event-category_edit_form_fields','extra_category_fields');  
add_action('event-category_add_form_fields','extra_category_fields'); 
share|improve this answer
    
I've seen this method before, like with managing post columns and such, does this work with most hooks? On that note, it doesn't seem to work - it removed them from Posts Categories but doesn't add them to my CPT Categories. Here's a pastebin with my CPT, Taxonomy, and Categories Fields - it seems to be spelled correctly. –  Howdy_McGee Sep 5 '13 at 14:50
    
These are the WordPress hooks. –  Vinod Dalvi Sep 5 '13 at 14:52
    
What's name of your CPT taxonomy? –  Vinod Dalvi Sep 5 '13 at 14:53
    
I added it all to a pastebin file Here –  Howdy_McGee Sep 5 '13 at 15:01
    
I have changed my code by referring your pastebin code. Test it now. –  Vinod Dalvi Sep 5 '13 at 15:04

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.