lagallega lagallega - 10 months ago 48
PHP Question

How to add custom metaboxes to taxonomies?

So I know how to save things when a taxonomy is edited like this:

if( !function_exists('mytaxonomysave') ):
function mytaxonomysave($term_id, $tt_id, $taxonomy) {
if($taxonomy == 'series'){
update_term_meta($term_id, 'type', $_POST['type']);
add_action( 'edit_term', 'mytaxonomysave', 10, 3 );

But I have no idea how to add a the metabox to the proper areas, what can I do? whats the correct hook¿

Answer Source

The hook you're looking for is: {taxonomy}_add_form_fields so in your case you use:

function series_types() {
    <div class="form-field term-description-wrap">
        <label for="tag-type">Type</label>
        <input type='text' name='tag-type'></input>
add_action('series_add_form_fields', 'series_types');