How to add the category ID to admin page

The hooks for taxonomies are:

  • "manage_edit-${taxonomy}_columns" for the header
  • "manage_edit-${taxonomy}_sortable_columns" to make columns sortable
  • "manage_${taxonomy}_custom_column" for the cell content

To catch all taxonomies write:

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:4em}</style>';
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)