WordPress 3.5 admin columns for custom taxonomies

WordPress 3.5 is here!! If you haven’t played with it yet, go get it!
I’m proud to be listed as a contributor on this release and want to highlight a new feature geared towards developers that I helped work on. If you have checked the register_taxonomy() codex page recently, you may have noticed a new optional argument, ‘show_admin_column.’

From the codex:

show_admin_column
(boolean) (optional) Whether to allow automatic creation of taxonomy columns on associated post-types.
Default: false

As stated, this new argument allows easy registration of taxonomy columns on post (and custom post type) list table screens much like the default tags’ and categories’ columns.

'show_admin_column' in action

This should make plugin and theme developers happy as they’ll no longer need to build these columns manually.

The new argument in action:

// hook into the init action and call create_activity_taxonomies when it fires
add_action( 'init', 'create_activity_taxonomies' );

// create taxonomy, "fitness-type" for the post type "activity"
function create_activity_taxonomies() {
	// Add new taxonomy, make it hierarchical (like categories)
	$labels = array(
		'name' => _x( 'Fitness Types', 'taxonomy general name' ),
		'singular_name' => _x( 'Fitness Type', 'taxonomy singular name' ),
		'search_items' => __( 'Search Fitness Types' ),
		'all_items' => __( 'All Fitness Types' ),
		'parent_item' => __( 'Parent Fitness Type' ),
		'parent_item_colon' => __( 'Parent Fitness Type:' ),
		'edit_item' => __( 'Edit Fitness Type' ),
		'update_item' => __( 'Update Fitness Type' ),
		'add_new_item' => __( 'Add New Fitness Type' ),
		'new_item_name' => __( 'New Fitness Type Name' ),
		'menu_name' => __( 'Fitness Type' ),
	);

	register_taxonomy( 'fitness-type', array( 'activity' ), array(
		'hierarchical' => true,
		'labels' => $labels,
		'show_ui' => true,
		'show_admin_column' => true,
		'query_var' => true,
		'rewrite' => array( 'slug' => 'fitness-type' ),
	) );
}

Another key addition is the “manage_taxonomies_for_{$post_type}_columns” filter. This allows developers to add a taxonomy column to a post type outside of the register_taxonomy() function:

Example:

add_filter( 'manage_taxonomies_for_activity_columns', 'activity_type_columns' );
function activity_type_columns( $taxonomies ) {
	$taxonomies[] = 'activity-type';
	return $taxonomies;
}