Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under our Support Policy.
Register the taxonomy for menus
When registering taxonomies for your custom attributes, WooCommerce calls the following hook:$show_in_nav_menus = apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name);So, for example, if your attribute slug was ‘size’ you would do the following to register it for menus:
add_filter('woocommerce_attribute_show_in_nav_menus', 'wc_reg_for_menus', 1, 2); function wc_reg_for_menus( $register, $name = '' ) { if ( $name == 'pa_size' ) $register = true; return $register; }
Custom attribute slugs are prefixed with ‘pa_’, so an attribute called ‘size’ would be ‘pa_size’
Now use your attribute in Appearance > Menus. You will notice, however, that it has default blog styling when you click on a link to your taxonomy term.
Create a template
You need to theme your attribute to make it display products as you want. To do this:- Copy woocommerce/templates/taxonomy-product_cat.php into your theme folder
- Rename the template to reflect your attribute – in our example we’d use taxonomy-pa_size.php