How can I hide tags in the Dawn theme for product filtering?

Hi

I am trying to hide certain tags from the filtering of products in my webshop. (Dawn theme)

I have tried this solution, but it is not working for me: https://community.shopify.com/c/technical-q-a/hide-tags-from-filter-in-dawn-theme/m-p/1900089/highlight/true#M116309

This is the error message I get: Liquid syntax error (snippets/facets line 200):Expected end_of_string but found id in “value contain ‘_’”

Can anyone help?

Ellen

Glad to help. Can you share the link to your website?

Hi:-)

https://vegaforlag.no/

Ellen

Hi:-)

@Zqdo The URL is https://vegaforlag.no/

Ellen

Thanks. Which tags are you trying to hide?

Hi

It will be some of the product tags under “kategori” (I have removed them from the products now, as I do not want them to be visible) I would like to hide tags containing _ (underscore)

Ellen

find the liquid that renders the tags filter, adding the data-value=“{{value}}” (value is the tag name/filter value)

and then in the CSS, create the display none for those tag that you want to hide

.facet-checkbox[data-value=“{{value}}”] {

display: none;

}

This is the easiest way.

Or you can try some filter app and exclude the filter option that you don’t want to show

https://apps.shopify.com/ultimate-search-and-filter-1

Can you show them momentarily, just until the issue is fixed? Thanks!

Thank you @minhcu

The liquid that renders the tag filters is facets.liquid in Sections I think. I am not sure where to add the code in this file?

{% comment %}
Renders facets (filtering and sorting)

Accepts:

  • results: {Object} Collection or Search object
  • enable_filtering: {Boolean} Show filtering when true
  • enable_sorting: {Boolean} Show sorting when true
  • filter_type: {String} Type of filter
  • paginate: {Object}

Usage:
{% render ‘facets’, results: collection, enable_filtering: true, enable_sorting: true, filter_type: ‘vertical’, paginate: paginate %}
{% endcomment %}

{{ ‘component-show-more.css’ | asset_url | stylesheet_tag }}

{%- liquid
assign sort_by = results.sort_by | default: results.default_sort_by
assign total_active_values = 0
if results.url
assign results_url = results.url
else
assign terms = results.terms | escape
assign results_url = ‘?q=’ | append: terms | append: ‘&options%5Bprefix%5D=last&sort_by=’ | append: sort_by
endif
-%}

{%- if filter_type == 'vertical' or filter_type == 'horizontal' -%} {%- if results.terms -%} {%- endif -%}

{% if enable_filtering %}
{% comment %} Heading is the first tabbable element on filter type horizontal {% endcomment %}

{%- if filter_type == 'horizontal' and results.filters != empty -%}

{{ 'products.facets.filter_by_label' | t }}

{%- endif -%} {% comment %} Pills are right below the title for filter type vertical {% endcomment %} {%- if filter_type == 'vertical' -%}
{%- unless results.filters == empty -%}

{{ 'products.facets.filter_by_label' | t }}

{%- endunless -%} {{ 'products.facets.clear_all' | t }}
{%- for filter in results.filters -%} {%- for value in filter.active_values -%} {{ filter.label }}: {{ value.label | escape }} {% render 'icon-close-small' %} {{ 'products.facets.clear_filter' | t }} {%- endfor -%} {% if filter.type == 'price_range' %} {%- if filter.min_value.value != null or filter.max_value.value != null -%} {%- if filter.min_value.value -%} {{ filter.min_value.value | money }} {%- else -%} {{ 0 | money }} {%- endif -%} - {%- if filter.max_value.value -%} {{ filter.max_value.value | money }} {%- else -%} {{ filter.range_max | money }} {%- endif -%} {% render 'icon-close-small' %} {{ 'products.facets.clear_filter' | t }} {%- endif -%} {% endif %} {%- endfor -%}
{%- endif -%}

{% comment %} Filters for both horizontal and vertical filter {% endcomment %}
{%- for filter in results.filters -%}
{%- assign total_active_values = total_active_values | plus: filter.active_values.size -%}
{% case filter.type %}
{% when ‘boolean’, ‘list’ %}

{{- filter.label | escape }} {%- if filter_type == 'vertical' -%} ({{ filter.active_values.size }}) {%- endif -%} {% render 'icon-caret' %}
{%- if filter_type != 'vertical' -%}
{{- 'products.facets.filters_selected' | t: count: filter.active_values.size -}} {{ 'products.facets.reset' | t }}
{%- endif -%} {{ filter.label | escape }}

    {%- for value in filter.values -%}

  • <svg
    width=“1.6rem”
    height=“1.6rem”
    viewBox=“0 0 16 16”
    aria-hidden=“true”
    focusable=“false”


    <svg
    aria-hidden=“true”
    class=“icon icon-checkmark”
    width=“1.1rem”
    height=“0.7rem”
    viewBox=“0 0 11 7”
    fill=“none”
    xmlns=“http://www.w3.org/2000/svg


    {{ value.label | escape }} ({{ value.count }})

    {{- value.label | escape }} (
    {%- if value.count == 1 -%}
    {{- ‘products.facets.product_count_simple.one’ | t: count: value.count -}}
    {%- else -%}
    {{- ‘products.facets.product_count_simple.other’ | t: count: value.count -}}
    {%- endif -%}
    )</span

  • {%- endfor -%}

{% comment %} No show more for no JS {% endcomment %}

    {%- for value in filter.values -%}
  • <svg
    width=“1.6rem”
    height=“1.6rem”
    viewBox=“0 0 16 16”
    aria-hidden=“true”
    focusable=“false”


    <svg
    aria-hidden=“true”
    class=“icon icon-checkmark”
    width=“1.1rem”
    height=“0.7rem”
    viewBox=“0 0 11 7”
    fill=“none”
    xmlns=“http://www.w3.org/2000/svg


    {{ value.label | escape }} ({{ value.count }})

    {{- value.label | escape }} (
    {%- if value.count == 1 -%}
    {{- ‘products.facets.product_count_simple.one’ | t: count: value.count -}}
    {%- else -%}
    {{- ‘products.facets.product_count_simple.other’ | t: count: value.count -}}
    {%- endif -%}
    )</span

  • {%- endfor -%}
{%- if filter.values.size > 10 and filter_type == 'vertical' -%} + {{ 'products.facets.show_more' | t -}} - {{ 'products.facets.show_less' | t -}} {%- endif %}
{% when 'price_range' %} {% liquid assign currencies_using_comma_decimals = 'ANG,ARS,BRL,BYN,BYR,CLF,CLP,COP,CRC,CZK,DKK,EUR,HRK,HUF,IDR,ISK,MZN,NOK,PLN,RON,RUB,SEK,TRY,UYU,VES,VND' | split: ',' assign uses_comma_decimals = false if currencies_using_comma_decimals contains cart.currency.iso_code assign uses_comma_decimals = true endif %}
{{ filter.label | escape }} {% render 'icon-caret' %}
{%- assign max_price_amount = filter.range_max | money | strip_html | escape -%} {{- 'products.facets.max_price' | t: price: max_price_amount -}} {%- if filter_type != 'vertical' -%} {{ 'products.facets.reset' | t }} {%- endif -%}
{{ cart.currency.symbol }}
{{- 'products.facets.from' | t -}}
{%- if filter_type != 'vertical' -%} {{ cart.currency.symbol }} {%- endif -%}
{{- 'products.facets.to' | t -}}
{% endcase %} {%- endfor -%} {{ 'products.facets.filter_button' | t }}
{% comment %} Pills after filtes on filter type horizontal {% endcomment %} {%- if filter_type == 'horizontal' -%} {%- endif -%} {% endif %}

{% if results.current_vendor or results.current_type %}

{% endif %}

{%- if filter_type == ‘horizontal’ -%}
{% comment %} Sorting and product count are the last elements when filter type is horizontal {% endcomment %}
{%- if enable_sorting -%}

{{ 'products.facets.sort_by_label' | t }}

{%- assign sort_by = results.sort_by | default: results.default_sort_by -%} {% render 'icon-caret' %}
{{ 'products.facets.sort_button' | t }}
{%- endif -%}

{%- if results.results_count -%} {{ 'templates.search.results_with_count' | t: terms: results.terms, count: results.results_count }} {%- elsif results.products_count == results.all_products_count -%} {{ 'products.facets.product_count_simple' | t: count: results.products_count }} {%- else -%} {{ 'products.facets.product_count' | t: product_count: results.products_count, count: results.all_products_count }} {%- endif -%}

{%- endif -%} {% comment %} Sorting for vertical filter are grouped with filter when no JS{% endcomment %} {%- if enable_sorting and filter_type == 'vertical' -%}

{{ 'products.facets.sort_by_label' | t }}

{%- assign sort_by = results.sort_by | default: results.default_sort_by -%} {% render 'icon-caret' %}
{{ 'products.facets.sort_button' | t }}

{% if results.current_vendor or results.current_type %}

{% endif %}

{%- if results.terms -%}


{%- endif -%}

{%- endif -%} {%- endif -%} {% comment %} Drawer and mobile filter {% endcomment %}
{% render 'icon-filter' %} {%- if enable_filtering and enable_sorting -%} {{ 'products.facets.filter_and_sort' | t }} {%- elsif enable_filtering -%} {{ 'products.facets.filter_button' | t }} {%- elsif enable_sorting -%} {{ 'products.facets.sort_button' | t }} {%- endif -%} {%- if enable_filtering -%} {{ 'products.facets.filter_button' | t }} {%- endif -%} {%- render 'icon-close' -%}

{%- if enable_filtering and enable_sorting -%} {{ 'products.facets.filter_and_sort' | t }} {%- elsif enable_filtering -%} {{ 'products.facets.filter_button' | t }} {%- elsif enable_sorting -%} {{ 'products.facets.sort_button' | t }} {%- endif -%}

{%- if enable_filtering -%} {{ 'products.facets.filter_button' | t }} {%- endif -%}

{%- if results.results_count -%} {{ 'templates.search.results_with_count' | t: terms: results.terms, count: results.results_count }} {%- elsif results.products_count == results.all_products_count -%} {{ 'products.facets.product_count_simple' | t: count: results.products_count }} {%- else -%} {{ 'products.facets.product_count' | t: product_count: results.products_count, count: results.all_products_count }} {%- endif -%}

{%- if enable_filtering -%} {%- for filter in results.filters -%} {% case filter.type %} {% when 'boolean', 'list' %}
{{ filter.label | escape }} {% render 'icon-arrow' %} {% render 'icon-caret' %}
{% render 'icon-arrow' %} {{ filter.label | escape }}
    {%- for value in filter.values -%}
  • <svg
    width=“1.6rem”
    height=“1.6rem”
    viewBox=“0 0 16 16”
    aria-hidden=“true”
    focusable=“false”


    <svg
    aria-hidden=“true”
    class=“icon icon-checkmark”
    width=“1.1rem”
    height=“0.7rem”
    viewBox=“0 0 11 7”
    fill=“none”
    xmlns=“http://www.w3.org/2000/svg

    {{ value.label | escape }} ({{ value.count }})

    {{- value.label | escape }} (
    {%- if value.count == ‘1’ -%}
    {{- ‘products.facets.product_count_simple.one’ | t: count: value.count -}}
    {%- else -%}
    {{- ‘products.facets.product_count_simple.other’ | t: count: value.count -}}
    {%- endif -%}
    )</span

  • {%- endfor -%}
{{- 'products.facets.clear' | t -}} {{ 'products.facets.apply' | t }} {{ 'products.facets.apply' | t }}
{% when 'price_range' %}
{{ filter.label | escape }} {% render 'icon-arrow' %} {% render 'icon-caret' %}
{% render 'icon-arrow' %} {{ filter.label | escape }}

{%- assign max_price_amount = filter.range_max | money | strip_html | escape -%}

{{ 'products.facets.max_price' | t: price: max_price_amount }}

{{ cart.currency.symbol }}
{{- 'products.facets.from' | t -}}

{{ cart.currency.symbol }}

{{- 'products.facets.to' | t -}}
{{- 'products.facets.clear' | t -}} {{ 'products.facets.apply' | t }} {{ 'products.facets.apply' | t }}
{% endcase %} {%- endfor -%} {%- endif -%}

{%- if enable_sorting -%}

{{ 'products.facets.sort_by_label' | t }}
{% render 'icon-caret' %}
{%- endif -%}
{{- 'products.facets.clear_all' | t -}} {{ 'products.facets.apply' | t }} {{ 'products.facets.apply' | t }}

{% if results.current_vendor or results.current_type %}

{% endif %}

{%- if results.terms -%}


{%- endif -%}

{% comment %} Sort, product count and filter pills at the end when filter is type of Drawer for the correct tabbing order {% endcomment %} {%- if enable_sorting and filter_type == 'drawer' -%}

{{ 'products.facets.sort_by_label' | t }}

{%- assign sort_by = results.sort_by | default: results.default_sort_by -%} {% render 'icon-caret' %}
{{ 'products.facets.sort_button' | t }}

{% if results.current_vendor or results.current_type %}

{% endif %}

{%- if results.terms -%}


{%- endif -%}

{%- endif -%}

{%- if results.results_count -%} {{ 'templates.search.results_with_count' | t: terms: results.terms, count: results.results_count }} {%- elsif results.products_count == results.all_products_count -%} {{ 'products.facets.product_count_simple' | t: count: results.products_count }} {%- else -%} {{ 'products.facets.product_count' | t: product_count: results.products_count, count: results.all_products_count }} {%- endif -%}

{%- if filter_type == 'drawer' -%} {%- endif -%}