A custom taxonomy in WordPress does not show up as a column in the admin post list unless it was registered with show_admin_column, and plugins often register theirs without it. This snippet adds taxonomy columns to the WordPress admin list of any post type, so you can see each post’s genres, brands or formats without opening it.
You list post types and taxonomies in one config array. Each column shows the post’s terms as links that filter the list, exactly like the built-in Categories and Tags columns.
The snippet
<?php
/**
* Show taxonomy columns in WordPress admin post lists.
*/
// ===== Config: post type => taxonomies to show as columns =====
function dpc_admin_taxonomy_columns_map() {
$map = array(
'post' => array( 'post_format' ),
// 'book' => array( 'genre', 'book_author' ),
// 'event' => array( 'event_type' ),
);
// ===== End of config =====
return (array) apply_filters( 'dpc_admin_taxonomy_columns_map', $map );
}
add_action( 'admin_init', 'dpc_admin_taxonomy_columns_register' );
function dpc_admin_taxonomy_columns_register() {
foreach ( array_keys( dpc_admin_taxonomy_columns_map() ) as $post_type ) {
add_filter( "manage_taxonomies_for_{$post_type}_columns", 'dpc_admin_taxonomy_columns_add', 10, 2 );
}
}
function dpc_admin_taxonomy_columns_add( $taxonomies, $post_type ) {
$map = dpc_admin_taxonomy_columns_map();
if ( empty( $map[ $post_type ] ) ) {
return $taxonomies;
}
foreach ( (array) $map[ $post_type ] as $taxonomy ) {
// Skip typos and taxonomies that are not attached to this post type.
if ( is_object_in_taxonomy( $post_type, $taxonomy ) ) {
$taxonomies[] = $taxonomy;
}
}
return array_values( array_unique( $taxonomies ) );
}
How it works
- WordPress builds the columns of a post list from every taxonomy with
show_admin_column, then passes that list through themanage_taxonomies_for_{$post_type}_columnsfilter. The snippet adds your taxonomies there, so WordPress renders the header, the term links and the filter links itself. - The config lives in
dpc_admin_taxonomy_columns_map(): post type slug on the left, taxonomy slugs on the right. The example adds the Format column to Posts. - The filters are added on
admin_init, after post types and taxonomies are registered, one filter per post type in the config. is_object_in_taxonomy()skips a taxonomy that does not exist or is not attached to that post type, so a typo gives no column instead of an empty one, andarray_unique()stops duplicates.- This works for taxonomies other plugins register, because it does not need to change their registration.
The older version of this post started with <? php, a syntax error, and needed {CPT_slug} and {taxonomy_slug} replaced by hand in the hook name.
Add it with Scripts Organizer
In Scripts Organizer go to Code Blocks → Add New and give the block a name. Set Trigger location to Admin only, tick PHP under Script location, paste the code into the PHP editor, edit the config array and publish. Leave Action/Hook empty. Post lists only exist in wp-admin, so Admin only is all it needs.
The same code also works unchanged in a small plugin or an mu-plugin.
Customise it
- Your own taxonomies: add a line such as
'book' => array( 'genre', 'book_author' ),to the config. Find the slugs in the URL of the taxonomy’s admin screen (taxonomy=genre&post_type=book). - Pages: use
'page' => array( 'your_taxonomy' ); the taxonomy must be registered for pages. - Your own taxonomy, registered in your own code: you don’t need this snippet; set
'show_admin_column' => trueinregister_taxonomy().
For more list columns see Show featured image in admin posts and pages table and Page, Post, and CPT ID in Admin columns.
Gotchas
- Each user can hide the column under Screen Options; if it doesn’t appear, check there first.
- The columns are not sortable. Sorting by term would need a custom query, and posts can have several terms.
- A post with many terms shows them all, comma-separated, which can make the column tall; hide columns you don’t need under Screen Options.
In the Scripts Organizer library Import it with one click from Scripts Organizer.