Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Rock Types

if ( ! function_exists( 'hm_register_tax_rock_types' ) ) {

// Register Custom Taxonomy
function hm_register_tax_rock_types() {

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

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

}