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
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024