Ecommerce Shopify WordPress Discussion

Create a custom taxonomy for WooCommerce without a plugin

I want to create custom taxonomy for WooCommerce. The default taxonomy is category and tag, however, I want more, for example, brands, materials and more. For instance, I want Nike, Adidas... to be under brands; leather, canvas... to be under materials. When I search online, most tutorials are using plugins, like Advanced Custom Fields, to create custom taxonomy for WooCommerce. However, I really don't want to use plugin for just one purpose. I found this online: however it is for creating taxonomy for custom post type. I instead want to create custom taxonomy for WooCommerce. Therefore, the code doesn't work for me. add_action('init', 'register_custom_taxonomy'); function register_custom_taxonomy() { $labels = array( 'name' => _x('Collections', 'taxonomy general name'), 'singular_name' => _x('Collection','taxonomy singular name'), 'search_items' => __('Search Collection'), 'all_items' => __('All Collection'), 'parent_item' => __('Parent Collection'), 'parent_item_colon' => __('Parent Collection:'), 'edit_item' => __('Edit Collection'), 'update_item' => __('Update Collection'), 'add_new_item' => __('Add New Collection'), 'new_item_name' => __('New Collection Name'), 'menu_name' => __('Collections'), ); $args = array( 'hierarchical' => true, // make it hierarchical (like categories) 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'show_in_rest' => true, 'rewrite' => array('slug' => 'Collection'), ); register_taxonomy('Collections', 'wpp_shoe', $args); // Register the Taxonomy } Anybody has solution?
To make your custom taxonomy linked to WooCommerce products, Some small adjustments are needed in your code (mainly to define "product" post type as the 2nd argument in register_taxonomy() function): add_action('init', 'register_woocommerce_custom_taxonomy'); function register_woocommerce_custom_taxonomy() { $text_domain = 'woocommerce'; // Register this custom taxonomy for "product" post type register_taxonomy('collection', array('product'), array( 'labels' => array( 'name' => _x('Collections', 'taxonomy general name', $text_domain), 'singular_name' => _x('Collection', 'taxonomy singular name', $text_domain), 'search_items' => __('Search Collection', $text_domain), 'all_items' => __('All Collection', $text_domain), 'parent_item' => __('Parent Collection', $text_domain), 'parent_item_colon' => __('Parent Collection:', $text_domain), 'edit_item' => __('Edit Collection', $text_domain), 'update_item' => __('Update Collection', $text_domain), 'add_new_item' => __('Add New Collection', $text_domain), 'new_item_name' => __('New Collection Name', $text_domain), 'menu_name' => __('Collections', $text_domain), ), 'hierarchical' => true, // Like categories 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'show_in_rest' => true, 'rewrite' => array('slug' => 'collection'), ) ); } Code goes on functions.php file of your child theme (or in a plugin). Tested and works.

February 26, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.