I am trying to add custom columns to edit-tags.php for a custom taxonomy that I have created. This custom taxonomy is called equipment-types and it only applies to one custom post type called equipment. I am trying to use the same filters and actions that I would use to add custom columns on the edit.php page. I was able to actually create the custom columns with this filter:

add_filter('manage_edit-equipment-types_columns', 'define_equip_types_columns');

However, I cannot seem to populate these columns with any data. Normally, for the edit.php page I would use the following action:

add_action('manage_posts_custom_column', 'my_post_type_columns_content'));

And then within the my_post_type_columns_content function I would conditionally output column data based on the post-type.

The problem is I can’t seem to find a similar hook for the edit-tags page. Adam Brown’s website lists these hooks:

manage_blogs_custom_column

manage_comments_custom_column

manage_comments_nav

manage_link_custom_column

manage_media_custom_column

manage_media_media_column

manage_pages_custom_column

manage_plugins_custom_column

manage_posts_custom_column

manage_sites_custom_column

manage_themes_custom_column

manage_{$post->post_type}_posts_custom_column

None of which I think would be any help. Does anyone know of a way to do this? I’m so close, I have the columns created with titles, I just need to fill them with data!

EDIT: To be clear, I am not trying to make custom fields. I am trying to make custom COLUMNS in the table to the right on the main taxonomy page.

Regularly on the edit.php page where it displays All Posts for that post type I can make custom columns such as the quantity column like this:

enter image description here

However, I don’t think there is a hook to populate the columns on the edit-tags.php main page, even though I can create a custom column such as Image URL below:

enter image description here

3 s
3

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 Reply

Your email address will not be published. Required fields are marked *