Ted Takeshi Doré
Ted Takeshi Doré

Reputation: 91

How do I change the order of my filter tags on my collection page?

Currently, my collection filter tags are displaying alphabetically. How do I go about changing this manually?

 {% if settings.collection_tags and collection.tags.size > 0 %}
    <nav class="filter-tag">
      <span class="mobile">{% unless current_tags %}{{ 'collections.sorting.title' | t }}{% endunless %}
            {% for tag in collection.all_tags %}
              {% if current_tags contains tag %}
                {{ tag | capitalize }}
              {% endif %}
            {% endfor %}
        </span>

Upvotes: 1

Views: 1666

Answers (1)

Steph Sharp
Steph Sharp

Reputation: 11682

I think you might need to do something like this and create an array of tags in the order you want:

{% assign tags = 'Small, Medium, Large' | split: ',' %}

{% for t in tags %}  
    {% assign tag = t | strip %}
    {% if current_tags contains tag %}
        ...
    {% endif %}
{% endfor %}

See here in the Shopify docs for another example.

Upvotes: 2

Related Questions