I want to add the categories ID to admin page.
I call it for my functions.php
: require_once('includes/categories_custom_id.php');
The part of code:
function categoriesColumnsHeader($columns) {
$columns['catID'] = __('ID');
return $columns;
}
add_filter( 'manage_categories_columns', 'categoriesColumnsHeader' );
function categoriesColumnsRow($argument, $columnName, $categoryID){
if($columnName == 'catID'){
return $categoryID;
}
}
add_filter( 'manage_categories_custom_column', 'categoriesColumnsRow', 10, 3 );
But it doesn’t work. Any idea, how to do that?
Thanks in advance.
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>';
}