Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

product_categories

// Register Custom Taxonomy
function product_taxonomy() {

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

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