Show Shopify Search & Discovery filter only on a specific collection?

Hi,

Does anyone know if it’s possible (or via a code snippet/workaround) to show a Shopify Search & Discovery filter only on a specific collection page? For example, I want the “Material” filter (TPE vs Silicone) to appear only on a specific collection, not across all collections.

Hey @Linda1994

Welcome to the community, first of all ignore the AI generated reply above which clearly is useless.

Secondly, can you share the URL of that specific collection where you only want to display that filter so I can have a look?

Best,
Moeed

Hi @Linda1994

One option is to create collection templates.

In the theme editor, go to your collections. Click, “create template” then base the new collection on your existing collection page.

Make any changes, you would like to the new template.

Then, go to the collection that you want to change.

In the settings, change the template to the newly created template.

Hi,

Hope this will help

  • Option 1: Use collection-specific templates

Create a new collection template and assign that template only to the collection where you want the Material filter

Example logic

{% for filter in collection.filters %}
  {% if filter.label == 'Material' %}
    {% render 'filter-material', filter: filter %}
  {% endif %}
{% endfor %}

  • Option 2: Hide the filter with JavaScript

Example of JS

if (window.location.pathname.includes('/collections/specific-collection-handle')) {
  document.querySelector('[data-filter-label="Material"]')?.style.display = 'block';
} else {
  document.querySelector('[data-filter-label="Material"]')?.style.display = 'none';
}

  • Option 3: Use a collection metafield to control visibility