Adrian
Adrian

Reputation: 523

Shopify get all collections with specific template

I am trying to create a Brands page in shopify. For that I have a custom page template page.brands and a custom template collection.brands.

Now I need to loop trough all collections and find only the ones using my custom template.

{% for collection in collections %}

  {{ template }} // template here returns 'page.brands' not 'collection.brands'

{% endfor %}

Found some solution to search by name but if I will add more collections I also have to add names to array.

Any help with that or there any way to do that?

Upvotes: 2

Views: 2262

Answers (1)

Adrian
Adrian

Reputation: 523

Found the answer in shopify documentation

{% for collection in collections %}
        
  {% if collection.template_suffix == "brands" %}
        
        {{ collection.title }} 
        
  {% endif %}
        
{% endfor %}

Upvotes: 1

Related Questions