Forums

Addiing to a custom taxonomy's write panel? (2 posts)

  1. jbobich
    Member
    Posted 1 year ago #

    Hello,

    Following this quick tutorial, I was able to successfully hook into the category write panels with the following:

    add_action('add_category_form', 'my_function_blahblah');
    add_action('edit_category_form', 'my_function_blahblah');
    add_action('create_category','my_function_blahblah');
    add_action('edit_category','my_function_blahblah');

    Now I'm trying to figure out if I can do the same thing for a custom taxonomy? Is it possible? Any clues? :-)

  2. Clearfly
    Member
    Posted 1 year ago #

    There are quite a few hooks you can use depending on where you want to add in your form fields.
    Open up edit-tags.php and edit-tag-form.php and look for any of the non deprecated do_action hooks like do_action($taxonomy . 'the hook name');

    The ones i found useful fire just before the submit button:
    On your Custom Taxonomy Add page you can use:
    add_action($taxonomy.'_add_form_fields', 'callback_function');
    On your Custom Taxonomy Edit page you can use:
    add_action($taxonomy.'_edit_form', 'callback_function');

    They pass the current $taxonomy_term to the callback function.

    In my case is did this:
    add_action('product-category_edit_form', 'category_meta_fields');
    add_action('product-category_add_form_fields', 'category_meta_fields');

    function category_meta_fields($term){
    print_r($term); // to see what you get passed
    }

    Hope that helps someone, as i spent a good hour trying to find this out.

Topic Closed

This topic has been closed to new replies.

About this Topic