Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Taxonomy: People Categories

Categories for an associated People CPT. Be sure to change text_domain to your own theme or child theme’s text_domain.

if ( ! function_exists( 'tax_people' ) ) {

// Register Custom Taxonomy
function tax_people() {

	$labels = array(
		'name'                       => _x( 'People Categories', 'Taxonomy General Name', 'text_domain' ),
		'singular_name'              => _x( 'People Category', 'Taxonomy Singular Name', 'text_domain' ),
		'menu_name'                  => __( 'People Categories', 'text_domain' ),
		'all_items'                  => __( 'All People Categories', 'text_domain' ),
		'parent_item'                => __( 'Parent People Category', 'text_domain' ),
		'parent_item_colon'          => __( 'Parent People Category:', 'text_domain' ),
		'new_item_name'              => __( 'New People Category', 'text_domain' ),
		'add_new_item'               => __( 'Add New People Category', 'text_domain' ),
		'edit_item'                  => __( 'Edit People Category', 'text_domain' ),
		'update_item'                => __( 'Update People Category', 'text_domain' ),
		'view_item'                  => __( 'View People Category', 'text_domain' ),
		'separate_items_with_commas' => __( 'Separate people categories with commas', 'text_domain' ),
		'add_or_remove_items'        => __( 'Add or remove people categories', 'text_domain' ),
		'choose_from_most_used'      => __( 'Choose from the most used people categories', 'text_domain' ),
		'popular_items'              => __( 'Popular people categories', 'text_domain' ),
		'search_items'               => __( 'Search People Categories', 'text_domain' ),
		'not_found'                  => __( 'Not Found', 'text_domain' ),
		'no_terms'                   => __( 'No people categories', 'text_domain' ),
		'items_list'                 => __( 'People categories list', 'text_domain' ),
		'items_list_navigation'      => __( 'People categories list navigation', 'text_domain' ),
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => false,
		'show_tagcloud'              => true,
		'show_in_rest'               => false,
	);
	register_taxonomy( 'cat_people', array( 'people' ), $args );

}
add_action( 'init', 'tax_people', 0 );

}