Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Categories

// Register Custom Taxonomy
function rub_create_product_category_taxonomy() {

	$labels = array(
		'name'                       => _x( 'Categories', 'Taxonomy General Name', 'rub' ),
		'singular_name'              => _x( 'Category', 'Taxonomy Singular Name', 'rub' ),
		'menu_name'                  => __( 'Categories', 'rub' ),
		'all_items'                  => __( 'All Categories', 'rub' ),
		'parent_item'                => __( 'Parent Category', 'rub' ),
		'parent_item_colon'          => __( 'Parent Category:', 'rub' ),
		'new_item_name'              => __( 'New Category Name', 'rub' ),
		'add_new_item'               => __( 'Add New Category', 'rub' ),
		'edit_item'                  => __( 'Edit Category', 'rub' ),
		'update_item'                => __( 'Update Category', 'rub' ),
		'separate_items_with_commas' => __( 'Separate categories with commas', 'rub' ),
		'search_items'               => __( 'Search categories', 'rub' ),
		'add_or_remove_items'        => __( 'Add or remove categories', 'rub' ),
		'choose_from_most_used'      => __( 'Choose from the most used categories', 'rub' ),
		'not_found'                  => __( 'Not Found', 'rub' ),
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => true,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => false,
	);
	register_taxonomy( 'product-category', 'custom_post_type', $args );

}

// Hook into the 'init' action
add_action( 'init', 'rub_create_product_category_taxonomy', 0 );