How to Add Custom Taxonomy To Woocomerce Plugin

I am trying to add a Custom Taxonomy to Woocommerce by targeting the product post type in woocommerce. I used following code and add them into function.php I am not getting any error message but the tax is not showing in the Woocommerce as well.
Can you please let me know how I can do this or what I am doing wrong here?

<?php
// Register Custom Taxonomy
function custom_taxonomy_Item()  {

$labels = array(
    'name'                       => 'Items',
    'singular_name'              => 'Item',
    'menu_name'                  => 'Item',
    'all_items'                  => 'All Items',
    'parent_item'                => 'Parent Item',
    'parent_item_colon'          => 'Parent Item:',
    'new_item_name'              => 'New Item Name',
    'add_new_item'               => 'Add New Item',
    'edit_item'                  => 'Edit Item',
    'update_item'                => 'Update Item',
    'separate_items_with_commas' => 'Separate Item with commas',
    'search_items'               => 'Search Items',
    'add_or_remove_items'        => 'Add or remove Items',
    'choose_from_most_used'      => 'Choose from the most used Items',
);
$args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => true,
    'show_ui'                    => true,
    'show_admin_column'          => true,
    'show_in_nav_menus'          => true,
    'show_tagcloud'              => true,
);
register_taxonomy( 'item', 'product', $args );

}
?>

Related posts

Leave a Reply

1 comment

  1. This php function is not being called, at least in this code. Make sure you are calling your custom_taxonomy_item and hook into init;

    add_action( 'init', 'custom_taxonomy_item', 0 );
    

    And place this above/below your code.