Skip to content

Instantly share code, notes, and snippets.

@bmodena
Last active July 22, 2016 14:40
Show Gist options
  • Save bmodena/7ff8841c85a4c1c19491 to your computer and use it in GitHub Desktop.
Save bmodena/7ff8841c85a4c1c19491 to your computer and use it in GitHub Desktop.
Exclude tags from collection.liquid filter when using tags to show related prodcuts
{% comment %}
Based on using Tags to show related products.
Credit : http://twigs.club/library/hand-picked-related-products-using-tags-or-metafields
{% endcomment %}
<div class="collection-sort">
<label for="SortBy" class="collection-sort__label">{{ 'collections.sorting.title_tags' | t }}</label>
<select name="SortTags" id="SortTags" class="collection-sort__input">
{% if collection.handle %}
<option value="/collections/{{ collection.handle }}">{{ 'collections.sorting.all_of_collection' | t: collection: collection.title }}</option>
{% elsif collection.current_type %}
<option value="{{ collection.current_type | url_for_type }}">{{ 'collections.sorting.all_of_collection' | t: collection: collection.title }}</option>
{% elsif collection.current_vendor %}
<option value="{{ collection.current_vendor | url_for_vendor }}">{{ 'collections.sorting.all_of_collection' | t: collection: collection.title }}</option>
{% endif %}
{% comment %}
Show all tags on the current collection of products and hide any that contain related-
{% endcomment %}
{% for tag in collection.all_tags %}
{% if tag contains 'related-' %} {% comment %} DO NOTHING {% endcomment %}
{% else %}
<option value="/collections/{% if collection.handle != blank %}{{ collection.handle }}{% else %}all{% endif %}/{{ tag | handleize }}"{% if current_tags contains tag %} selected="selected"{% endif %}>{{ tag }}</option>
{% endif %}
{% endfor %}
</select>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment