Is there anyway i can use the 'where' filter on collection.all.products to filter by tags?

Topic summary

A developer needs to filter products from collections.all.products by tag using Liquid’s where filter, but cannot create separate collections for organizational reasons.

Technical Limitation:

  • The where filter only works on simple properties of array items, not on complex objects or nested arrays
  • Tags don’t function as a single filterable property despite their convenience behaviors in Liquid

Recommended Solutions:

  1. Use tag-filtered collection URLs (/collections/collectionname/tagname) instead of looping through all products
  2. Implement client-side fetching via AJAX or the Section Rendering API with a special template
  3. Create a dedicated collection with conditions based on the target tag

Resolution: The original poster accepted these alternatives, acknowledging the technical constraint and planning to implement one of the suggested workarounds.

Summarized with AI on November 25. AI used: claude-sonnet-4-5-20250929.

No.

The where filter operates on the passed array based on a property of the individual items in that aray.

Not on objects, or an objects arrays

A resources tags have some convenience behaviors when working with them but they aren’t a single property which of course leads to hopeful expectations they should be useful for something like the |where: filter.

Currently this is solved with either:

A specific collection setup with conditions based on the target tag.

Or if you can do this on the client side just fetch that tag filter collection url using a special template you use specifically for ajax or the section rendering api. Keeping in mind pagination.

/collections/collectionname/tagname

What you don’t want to do is try to loop over all products in an ALL collection.