All things Shopify and commerce
Does anyone have an approach for showing collections on a page based on keyword?
For example, if I have 1,000 collections and I want to list 50 of them on a page that have keyword "poster" in their title, how can I do that?
Right now my theme has a nice widget for manually choosing collections to list on a page, but for 50 that's a lot of tedious work. I'd like to automate this sort of thing.
Has anybody found an app for dynamically showing collections on a page based on filters?
Solved! Go to the solution
This is an accepted solution.
Hi,
If you are referring to the main collection list we could use the liquid contains filter inside the collection for loop. For example
{%- for collection in collections -%}
{%- if collection.title contains 'poster' -%} <!-- This filters collections with 'poster' in the title -->
<li class="collection-list__item grid__item {% unless collection.featured_image != blank %} no-image__item{% endunless %}">
<!-- Your existing code for displaying the collection goes here -->
</li>
{%- endif -%}
{%- endfor -%}
This is an accepted solution.
Hi,
If you are referring to the main collection list we could use the liquid contains filter inside the collection for loop. For example
{%- for collection in collections -%}
{%- if collection.title contains 'poster' -%} <!-- This filters collections with 'poster' in the title -->
<li class="collection-list__item grid__item {% unless collection.featured_image != blank %} no-image__item{% endunless %}">
<!-- Your existing code for displaying the collection goes here -->
</li>
{%- endif -%}
{%- endfor -%}
Thank you. That's helpful.
I wish there was a way to insert Liquid code into page content without having to make a template just for that page.
No problem, yeah that would be helpful.
If you need anything else just us know.
Kind regards, Liam
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025