Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#21222 closed defect (bug) (invalid)

Unable to add columns to the Terms List table

Reported by: dglingren's profile dglingren Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: Taxonomy Keywords:
Focuses: Cc:


The base class WP_List_Table and its extended family is a great addition to the WordPress administration API. The WP_Posts_List_Table class has well-documented filters that support adding custom columns to the default table.

However, custom column support in the WP_Terms_List_Table class is incomplete. There is a filter in the column_default method, but it is useless because there is no filter in the get_columns method to allow expanding the column array.

Please consider changing the last line of the get_columns method to something like:

return apply_filters( "manage_{$taxonomy}_custom_get_columns", $columns );


return apply_filters( "manage_{$taxonomy}_columns", $columns );

The affected file is wp-admin/includes/class-terms-list-table.php. The choice for the filter name depends on whether you want to follow the convention used in the WP_Terms_List_Table class (first alternative) or the convention used in the WP_Posts_List_Table class (second alternative).

This one-line change would finish the job of making the default table expandable. Thank you for your consideration.

Change History (8)

#1 @dglingren
12 years ago

  • Cc david@… added

#2 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

You can use manage_{$screen->id}_columns filter from WP_List_Table:

For categories and tags, it's manage_edit-category_columns and manage_edit-post_tag_columns.

Closing as a duplicate of #20913.

#3 @michelwppi
12 years ago

  • Cc contact@… added
  • Resolution invalid deleted
  • Status changed from closed to reopened

To add the columns this filter manage_edit-category_columns is ok (add columns and title)


to fill each line of terms the filter "manage_{$screen->taxonomy}_custom_column" must not be a filter(if used: only first filter is possible as returned content and the other filter must echo the row ;-).

It must be an action like in line 671 of wp-posts-list-table

do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );

so in line 318 solution fixe is

do_action( "manage_{$screen->taxonomy}_custom_column",  $column_name, $tag->term_id );

Hope that help to understand our tests


Last edited 12 years ago by michelwppi (previous) (diff)

#4 @nacin
12 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

Line 319, give or take:

return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );

Return your content (rather than echoing, as occurs with the posts table).

#5 @michelwppi
12 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

BUT if you have two (or more filters), only the first returned value is displayed and for the second filter (another added column) you must echo..

#6 @nacin
12 years ago

Works fine for me:

add_filter( 'manage_edit-post_tag_columns', function( $cols ) {
	$cols['col1'] = 'Column 1';
	$cols['col2'] = 'Column 2';
	return $cols;
} );

add_filter( 'manage_post_tag_custom_column', function( $content, $column, $term_id ) {
	return "We are in $column for $term_id";
}, 10, 3 );

#7 @michelwppi
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

OK, you are right - the mistake came from first param 'empty' kept as a dummy var and not the content ... I change my way to manage content like here:

function co_manage_tax_column ( $content, $name, $id ) {
	if( $name != 'linked-post' )
			return $content;
	global $taxonomy ;
	$term = get_term((int)$id , $taxonomy ) ;	
	$a = $term->slug;
	//echo '<div>*'. $a .'</div>';	
	return $content.$a;	
add_filter( 'manage_category_custom_column', 'co_manage_tax_column', 12, 3);

and now, no interferences between the 2 filters for the two added columns.

Many thanks for your help to go deeper


Last edited 12 years ago by michelwppi (previous) (diff)

#8 @nacin
12 years ago

  • Resolution changed from fixed to invalid
Note: See TracTickets for help on using tickets.