How to add Custom Taxonomy to Woocommerce Product post type

Custom taxonomy is usually used for storing more data and to show more details about the product.
For example if you selling art and you want to show the artist name for the painting then custom taxonomy would be quite a  good option for you to use as you can add description about the artist so on so forth.

Here’s how easily you can add custom taxonomy to your woocommerce product post type.

You have to add the following code to your function.php in your theme file.

add_action( 'init', 'custom_taxonomy_Item' );

// Register Custom Taxonomy
function custom_taxonomy_Item() {

$labels = array(
'name' => 'Artists',
'singular_name' => 'Artist',
'menu_name' => 'Artist',
'all_items' => 'All Artist',
'parent_item' => 'Parent Artist',
'parent_item_colon' => 'Parent Artist:',
'new_item_name' => 'New Artist Name',
'add_new_item' => 'Add New Artist',
'edit_item' => 'Edit Artist',
'update_item' => 'Update Artist',
'separate_items_with_commas' => 'Separate Artist with commas',
'search_items' => 'Search Artist',
'add_or_remove_items' => 'Add or remove Artist',
'choose_from_most_used' => 'Choose from the most popular Artist',
$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( 'artist', 'product', $args );

add taxonomy

You just have to change the taxonomy name as per your needs.

Leave A Comment

Your email address will not be published. Required fields are marked *