Add tag filtering in Shopify
To implement a tag filtering feature, you can loop through all of the product tags in the collection using the all_tags
attribute of the collection
object.
{% if collection.all_tags.size > 0 %} <ul class="tag-filters"> {% for tag in collection.all_tags %} {% if current_tags contains tag %} <li class="tag-filters__item active">{{ tag | link_to_remove_tag: tag }}</li> {% else %} <li class="tag-filters__item">{{ tag | link_to_add_tag: tag }}</li> {% endif %} {% endfor %} </ul> {% endif %}