I've got a custom post type, Staff, and this post type has a custom taxonomy, Roles. I would like to be able to sort by/see roles on all staff page in the wp-admin backend like how categories and tags work by default for posts.
Thanks
Custom post type
function register_staff(){
$labels = array(
'name' => 'Staff',
'singular_name' => 'Staff',
'add_new' => 'Add Staff',
'all_items' => 'All Staff',
'add_new_item' => 'Add Staff Member',
'edit_item' => 'Edit Staff Member',
'new_item' => 'New Staff Member',
'view_item' => 'View staff',
'search_item' => 'Search staff',
'not_found' => 'No Items Found',
'not_found_in_trash' => 'No staff found in trash',
);
$args = array(
'labels' => $labels,
'public' => false,
'show_ui' => true,
'has_index' => true,
'has_archive' => true,
'publicly_queryable' => true,
'query_var' => true,
'has_archive' => true,
'rewrite' => true,
'capability_type' => "post",
'hierarchical' => false,
'supports' => array(
'title',
'editor',
'page-attributes',
'excerpt',
'thumbnail',
'revisions',
),
'taxonomies' => array("role"),
'menu_position' => 5,
'menu_icon' => "dashicons-businessperson",
'exclude_from_search' => false,
);
register_post_type('staff', $args);
}
add_action( "init", "register_staff");
Custom Taxonomy
add_action( "init", "register_staff");
function build_taxonomies() {
register_taxonomy('role', 'staff', array(
'label' => 'Roles',
'public' => true,
));
}
add_action( 'init', 'build_taxonomies', 0 );
See https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
Untested like this: