Custom columns on edit-tags.php main page

You can do this by hooking into the ‘taxonomy’_edit_form and edited_’taxonomy’ actions.

add_action('taxonomy_edit_form', 'foo_render_extra_fields');
function foo_render_extra_fields(){
    $term_id = $_GET['tag_ID'];
    $term = get_term_by('id', $term_id, 'taxonomy');
    $meta = get_option("taxonomy_{$term_id}");
    //Insert HTML and form elements here
}

add_action('edited_taxonomy', 'bar_save_extra_fields', 10, 2);
function bar_save_extra_fields($term_id){
    $form_field_1 = $_REQUEST['field-name-1'];
    $form_field_2 = $_REQUEST['field-name-2'];
    $meta['key_value_1'] = $form_field_1;
    $meta['key_value_2'] = $form_field_2;
    update_option("taxonomy_{$term_id}", $meta);
}

Make sure to change ‘taxonomy’ throughout the code example with your custom taxonomy. Be advised, this will only display on when a user edits a tag or category.

Update to add columns to the edit tags table:

function add_post_tag_columns($columns){
    $columns['foo'] = 'Foo';
    return $columns;
}
add_filter('manage_edit-post_tag_columns', 'add_post_tag_columns');

function add_post_tag_column_content($content){
    $content .= 'Bar';
    return $content;
}
add_filter('manage_post_tag_custom_column', 'add_post_tag_column_content');

This works like a charm! Here’s a screenshot: http://3-3.me/lFdf

Leave a Comment