How to put collection name to vendor?

Hey guys, I might need your help with something. I am looking for solution how to add to vendor collection name. I have found this code and put it to main product liquid:

{% for collection in product.collections %}

{{ collection.title }}

{% endfor %}

It is working just fine BUT If the product has more collection, then it shows all of them. Is there any solution how to edit this code to show only one collection and not all of them? Thank you

Hi @Vlk1 ,

May I suggest 2 solutions below:

  1. code to show the first collection
{%  assign collection = product.collections | first %} 
{{ collection.title }}
  1. Add “within: collection” to url of product. In product liquid only use {{ collection.title }} to show it.

Hey, thank you. I am not sure if I got it right but when I put it to product liquid, nothing happend.

Hi,

If you used in Assets/card_product.liquid. May I suggest code below:

{%  assign collection = card_product.collections | first %} 
{{ collection.title }}

I have edited it but it shows still name of my store as a vendor, not collection

Hi,

Could you please share your store url that you applied code?