Iterate field from an object reference, within a metaobject

Topic summary

Issue: A Shopify theme developer is trying to access and display field values from metaobject references within another metaobject. Specifically, they have a ‘support’ metaobject with a ‘categories’ field that contains a list of metaobject references (GIDs).

Problem Details:

  • The categories field returns only GIDs like ["gid://shopify/Metaobject/99266363722"]
  • Initial attempts to iterate and retrieve the referenced metaobject data (e.g., category names) failed
  • A suggested solution using shop.metaobjects.categories[category_id] didn’t work, returning blank values

Resolution: The original poster eventually solved the issue independently. The solution requires using the map filter with the specific field key name to extract values from metaobject references:

{% assign categoryNames = selectedCategories.categories.value | map: 'name' %}
{% for categoryName in categoryNames %}
  {{ categoryName }}
{% endfor %}

This approach successfully retrieves field values (like ‘name’) from the referenced metaobjects instead of just displaying GIDs.

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

Bump - if anyone has any ideas on this, it would be much appreciated!