Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Taxonomy – Publications

‘pub_types’ taxonomy for a post type called Publications.

if ( ! function_exists( 'pub_types' ) ) {

// Register Custom Taxonomy
function pub_types() {

	$labels = array(
		'name'                       => _x( 'Publication Types', 'Taxonomy General Name', 'understrap' ),
		'singular_name'              => _x( 'Publication Type', 'Taxonomy Singular Name', 'understrap' ),
		'menu_name'                  => __( 'Publication Types', 'understrap' ),
		'all_items'                  => __( 'All Publication Types', 'understrap' ),
		'parent_item'                => __( 'Parent Publication Type', 'understrap' ),
		'parent_item_colon'          => __( 'Publication Type:', 'understrap' ),
		'new_item_name'              => __( 'New Publication Type', 'understrap' ),
		'add_new_item'               => __( 'Add Publication Type', 'understrap' ),
		'edit_item'                  => __( 'Edit Publication Type', 'understrap' ),
		'update_item'                => __( 'Update Publication Type', 'understrap' ),
		'view_item'                  => __( 'View Publication Type', 'understrap' ),
		'separate_items_with_commas' => __( 'Separate Publication Types with commas', 'understrap' ),
		'add_or_remove_items'        => __( 'Add or remove Publication Types', 'understrap' ),
		'choose_from_most_used'      => __( 'Choose from the most used Publication Types', 'understrap' ),
		'popular_items'              => __( 'Popular Publication Types', 'understrap' ),
		'search_items'               => __( 'Search Publication Types', 'understrap' ),
		'not_found'                  => __( 'Publication Type(s) Not Found', 'understrap' ),
		'no_terms'                   => __( 'No Publication Types', 'understrap' ),
		'items_list'                 => __( 'Publication Types list', 'understrap' ),
		'items_list_navigation'      => __( 'Publication Types list navigation', 'understrap' ),
	);
	$rewrite = array(
		'slug'                       => 'pubtypes',
		'with_front'                 => true,
		'hierarchical'               => false,
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
		'query_var'                  => 'pubtypes',
		'rewrite'                    => $rewrite,
		'show_in_rest'               => true,
	);
	register_taxonomy( 'pub_types', array( 'publications' ), $args );

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

}