Displaying the new meta field object attributes via liquid

Topic summary

A user needs help displaying Shopify’s auto-generated category smart metafields using Liquid code in a custom theme snippet.

Current situation:

  • Successfully displays custom single/multi-line text metafields using standard Liquid syntax (e.g., product.metafields.custom.flavour)
  • The new metafield in question is a metaobject attribute with choices/options
  • ID is “shopify.dietary-preferences” with metaobject ID “shopify–dietary-preferences”

Problem:

  • Cannot use the same Liquid code approach that works for regular metafields
  • Unclear which syntax is needed to access and display metaobject attributes with multiple choice values

Status: Question remains unanswered; user is seeking the correct Liquid syntax equivalent to their existing if statement pattern for these newer metaobject-type fields.

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

can any one help with using liquid code to display the metafields that shopify generates for products.

since shopify started auto-generating these category smart metafields for products we start using them. However i need to add some into a custom code snippet from my store theme.

usually for the metafield single text line (multiple lines) metafields i created i use:-

{% if product.metafields.custom.flavour != blank %}
<p>Flavour:<br>
{{ product.metafields.custom.flavour.value | join:', ' }}
</p>
{% endif %}

this works great. However the new shopify metafield seems to be metaobject attribute and i cannot seem to use the liquid code above. The metafield in question is a number of choices so and its id is “shopify.dietary-preferences”, but the meta object id is “shopify–dietary-preferences” which do i need to use and what would be the correct use similiar to my ‘if statements’?

Hi @jamarzy

That new Shopify metafield is a metaobject reference, not a simple text list, so the code is different.

You need to use shopify.dietary-preferences and loop through the list to access each item’s name. The .join filter won’t work.

{%- assign preferences = product.metafields.shopify.dietary-preferences.value -%}

{%- if preferences.size > 0 -%}
  <p>Dietary Preferences:<br>
    {%- for item in preferences -%}
      {{ item.name }}{%- unless forloop.last -%}, {%- endunless -%}
    {%- endfor -%}
  </p>
{%- endif -%}

Hope this helps!