Created
October 13, 2017 10:01
-
-
Save veirus/c4056a5a738cd0522f21fbabd2a1b6e5 to your computer and use it in GitHub Desktop.
Show taxonomy ID in wordpress admin panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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