Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adding custom column displaying in Wordpress Manage Category/Custom Taxonomy editing page
Purpose: add custom column header and custom column content to respective custom header in Manage Category Editing Page
Version Tested: 3.8
Because I found no explanation nor documents in, I tried to trace the code in wp-admin folder
after understanding the operation of apply_filter(), add_action() and add_filter()
The table list in edit_tag.php is based on
wp-admin/includes/class-wp-list-table.php and
Note: actually class-wp-terms-list-table.php is creating a class extend the basic table list class in class-wp-list-table.php
// Example
// these filters will only affect custom column, the default column will not be affected
// filter: manage_edit-{$taxonomy}_columns
function custom_column_header( $columns ){
$columns['order_unit'] = 'Order Unit';
return $columns;
add_filter( "manage_edit-shop-subcategory_columns", 'custom_column_header', 10);
// parm order: value_to_display, $column_name, $tag->term_id
// filter: manage_{$taxonomy}_custom_column
function custom_column_content( $value, $column_name, $tax_id ){
// var_dump( $column_name );
// var_dump( $value );
// var_dump( $tax_id );
// for multiple custom column, you may consider using the column name to distinguish
// although If clause is working, Switch is a more generic and well structured approach for multiple columns
// if ($column_name === 'header_name') {
// echo '1234';
// }
switch( $column_name ) {
case 'header_name1':
// your code here
$value = 'header name 1';
case 'header_name2':
// your code here
$value = 'header name 2';
// ... similarly for more columns
return $value; // this is the display value
add_action( "manage_shop-subcategory_custom_column", 'custom_column_content', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment