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:
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:
You can do this by hooking into the ‘taxonomy’_edit_form and edited_’taxonomy’ actions.
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:
This works like a charm! Here’s a screenshot: http://3-3.me/lFdf
Just for posterity, because I, like @IV4 still had a bit of wrangling to do with @Brian’s answer to get it to work for a custom tax:
So in my case, my custom taxonomy was “product-category”, so it looked like this for me:
It should also be noted (though veterans will already know this) that for a taxonomy custom column you can ONLY create custom row data for columns that are not defined by default. The reason for this is that within the
WP_Terms_List_Table
class, unlike the way theWP_Posts_List_Table
class works, the custom column action is only called through thecolumn_default
method, which is only invoked if the column name does not match one of the default columns defined in that class (cb, description, links, name, posts, slug).In my case I wanted to modify the description column, but had to resort to creating a custom column called ‘summary’ instead. Also note that custom columns would have to be added to the sort filter if you wanted to sort on that column (though sorting on a description column didn’t make sense in my case).
In terms of the action’s function signature, it can take up to 3 arguments, the first of which is actually useless (which makes me wonder how @Brian’s answer worked at all):
Where
$value
is basically empty,$column
is what you want to switch on and$term_id
could be very important if you need to reference any data contained in your term!For adding on the main screen:
For adding on individual term edit form:
I’ve tested this, it works. See the screens:
,.
Replace
<taxonomy name>
with ‘category’ if you want this on the regular post categories. For saving the values wherever you want, you will need: