I’ve registered a new taxonomy for my custom post type, and now I’m trying to edit the taxonomy table.
I’ve successfully removed the description column but I can’t figure it out how to edit column width for the column that shows the number of custom post types found in that particular taxonomy. The column’s CSS class seems to be column-posts
, and thus, its width is set to 10%
.
Shouldn’t the column’s CSS class be column-{my-custom-post-type}
and not the default?
Can I somehow force the column’s width be set to auto
or set its class to match my custom-post-type?
Here’s what I’ve done so far:
Custom Post Type
function registerPersonnelPostType() {
$labels = array(
'name' => __( 'Personnel', 'xxx' ),
'singular_name' => __( 'Personnel', 'xxx' ),
'add_new' => __( 'Add New', 'xxx' ),
'add_new_item' => __( 'Add New Personnel Member', 'xxx' ),
'edit_item' => __( 'Edit Personnel Member', 'xxx' ),
'new_item' => __( 'New Personnel Member', 'xxx' ),
'view_item' => __( 'View Personnel Member', 'xxx' ),
'search_items' => __( 'Search Personnel', 'xxx' ),
'not_found' => __( 'No personnel found', 'xxx' ),
'not_found_in_trash' => __( 'No personnel found in Trash', 'xxx' ),
'parent_item_colon' => __( 'Parent Personnel:', 'xxx' ),
'menu_name' => __( 'Personnel', 'xxx' )
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'description' => 'Staff names and descriptions',
'supports' => array( 'title', 'editor', 'thumbnail' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'personnel', $args );
}
Taxonomy
function departmentInit() {
$labels = array(
'name' => __( 'Department', 'xxx' ),
'singular_name' => __( 'Department', 'xxx' ),
'search_items' => __( 'Search Departments', 'xxx' ),
'all_items' => __( 'All Departments', 'xxx' ),
'parent_item' => __( 'Parent Department', 'xxx' ),
'parent_item_colon' => __( 'Parent Department:', 'xxx' ),
'edit_item' => __( 'Edit Department', 'xxx' ),
'update_item' => __( 'Update Department', 'xxx' ),
'add_new_item' => __( 'Add New Department', 'xxx' ),
'new_item_name' => __( 'New Department Name', 'xxx' ),
'menu_name' => __( 'Department', 'xxx' )
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'department' )
);
register_taxonomy( 'department' , array('personnel'), $args );
}
Hooks for editing columns
add_filter( 'manage_edit-department_columns', 'departmentColumns' );
function departmentColumns( $columns ) {
if ( isset( $columns[ 'description' ] ) ) {
unset( $columns[ 'description' ] );
}
return $columns;
}
This should do the trick:
Add following code in functions.php file to achieve this :