Disclaimer: I don’t have enough rep on this site to add comments asking for more details so I’ll try to add a proper answer without …
Assuming your custom taxonomy DOES work, and you have added at least 1 of them to your products…
The next step is to edit your meta template for the single product page.
- Copy/paste the
/wp-content/plugins/woocommerce/templates/single-product/meta.php
to/wp-content/*your_theme*/woocommerce/single-product/meta.php
Note: If you’re using a child theme.. Then this goes into your child-theme folder. Not the parent theme.
For reference on everything going on in that page see your Single product’s template file at woocommerce/templates/content-single-product.php
. You can overwrite this one too if needed.
- Add this to your functions.php file:
function custom_product_meta_tax() {
global $product;
$taxonomy = 'collection'; // <== Here set your custom taxonomy
if( ! taxonomy_exists( string $taxonomy ) )
return; // exit
$term_ids = wp_get_post_terms( $product->get_id(), $taxonomy, array('fields' => 'ids') );
if ( ! empty($term_ids) ) {
echo get_the_term_list( $product->get_id(), 'collection', '<span class="posted_in">' . _n( 'Collection:', 'Collections:', count( $term_ids ), 'woocommerce' ) . ' ', ', ', '</span>' );
}
}
- In your meta.php (step 1), add this between the categories and the tags (line 35ish):
<?php custom_product_meta_tax(); ?>
That should do the trick. I did not test this manually but should work.
If it doesn’t, let me know and please add your code to these other files so I can see where the issue may be.