I use tags in my webshop for customers so they can filter on certain products that they’re searching. But I would like to use tags for me as well in de the backend without customers seeing them.
I know there are several ways to import this. I found this that I would like to use:
Browse by tag:
So if I start a tag with _ it doesn’t how up in the frontend of the webshop.
But I can’t seem to find the exact spot where I should add this code. I took over this webshop from a colleague that isn’t working with us anymore, and I don’t always understand his coding.
{% for tag in collection.all_tags %}
{%- assign new_url = tag | link_to_tag: tag | split: 'href="' | last | split: '"' | first -%}
{% endfor %}
With this:
{% for tag in collection.all_tags %}
{% if tag contains '_' %}
{%- assign new_url = tag | link_to_tag: tag | split: 'href="' | last | split: '"' | first -%}
{% endif %}
{% endfor %}
I changed the code, but now only the tags with ‘_’ in front will show up in the frontend of the store, whereas I don’t want the _tags to show up, only the tags without a _ prefix.
Got it. Can you please replace that code with the below one?
{% for tag in collection.all_tags %}
{% unless tag contains '_' %}
{%- assign new_url = tag | link_to_tag: tag | split: 'href="' | last | split: '"' | first -%}
{% endunless %}
{% endfor %}
Can you please provide what .liquid to enter this code and were in the code to place it. I want to be able to filter out tags from the “Filter and Sort” option on my website (see link to screenshot below) NOTE: My Theme is Sunrise and is Shopify Online 2.0 (latest update).