Struggling to display only the metaobject attached to a metafield in liquid

Topic summary

A user is attempting to display metaobject data on individual product pages in Shopify Liquid but encounters issues with filtering.

The Setup:

  • Two metaobjects exist: “discography” (containing release information) and “variants” (containing pressing details)
  • The discography metaobject has a metafield that references the variants metaobject
  • A discography listing page successfully displays all releases

The Problem:
On individual product pages, the code displays all variant entries from the entire shop instead of only the variants attached to the specific discography metafield. The user cannot figure out how to filter and display only the related variants.

Attempted Solutions:

  • Another user suggested changing shop.metaobjects.variants.values to variant.metaobjects.variants.values, but this returned null
  • A follow-up suggestion involved looping through product.variants and accessing metaobjects from there, but results are unclear

Status: The issue remains unresolved. The conversation includes code snippets (some appearing corrupted/reversed in the original text) showing various attempts to access the metafield relationship correctly.

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

I have a metaobject called “discography” with a number of metafields giving information about releases, one metafield discography.variants references another metaobject called variants which includes information about various pressings.

I have a discography page which displays packshots for all of my releases using this code [I’ve removed my website name just for privacy :slightly_smiling_face:


  {% for discography_item in shop.metaobjects.discography.values %}
  
      [
 
      {% if discography_item.packshot %}
      
          
    
      {% endif %}
      ### 
       {{ discography_item.title }}
      
      

        Catalog #: {{ discography_item.catalog_number }}
      

        ](https://store.website.com{{ discography_item.system.url }})
  {% endfor %}

But on the individual pages I can’t figure out how to display the variants metafield / metaobject?

This prints information for EVERY variant entry not just the entries that are attached to the discography.variants metafield?

<div class="discography-variants">
  <h3>Variants:</h3>
  <ul>
    {% for variant in shop.metaobjects.variants.values %}
    
        <li>
          <strong>{{ variant.pressing_info }}</strong>
        </li>
     
    {% endfor %}
  </ul>
</div>

Sorry if any of that isn’t described well.

Please help!

Hi @crumbscrumbs ,

Please change code:

shop.metaobjects.variants.values => variant.metaobjects.variants.values

Unfortunately with that change nothing displays?

All Variants: {{ variant.metaobjects.variants.values | json }}
returns null.

Variants:

    {% for variant in variant.metaobjects.variants.values %}
  • {{ variant.pressing_info }}
  • {% endfor %}

Hi @crumbscrumbs ,

The variant declared? If not, please change the code below:

{% for variant_product in product.variants %}

All Variants: {{ variant_product.metaobjects.variants.values | json }}


 returns null.

### Variants:

{% for variant in variant_product.metaobjects.variants.values %}

- **{{ variant.pressing_info }}**

{% endfor %}

{% endfor %}