Skip to content

Instantly share code, notes, and snippets.

@veirus
Created October 13, 2017 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veirus/c4056a5a738cd0522f21fbabd2a1b6e5 to your computer and use it in GitHub Desktop.
Save veirus/c4056a5a738cd0522f21fbabd2a1b6e5 to your computer and use it in GitHub Desktop.
Show taxonomy ID in wordpress admin panel
// show tax id's in admin panel:
// https://wordpress.stackexchange.com/a/77536
foreach ( get_taxonomies() as $taxonomy ) {
add_action( "manage_edit-${taxonomy}_columns", 't5_add_col' );
add_filter( "manage_edit-${taxonomy}_sortable_columns", 't5_add_col' );
add_filter( "manage_${taxonomy}_custom_column", 't5_show_id', 10, 3 );
}
add_action( 'admin_print_styles-edit-tags.php', 't5_tax_id_style' );
function t5_add_col( $columns )
{
return $columns + array ( 'tax_id' => 'ID' );
}
function t5_show_id( $v, $name, $id )
{
return 'tax_id' === $name ? $id : $v;
}
function t5_tax_id_style()
{
print '<style>#tax_id{width:3em;max-width:4em}</style>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment