{% for reference in metaobject.references %}

I’m unable to access References that belong to a MetaObject.

This should be possible using something like {% for reference in metaobject.references %}. As you know, a MetaObject can contain References to other MetaObjects, Articles, etc., but I haven’t found a way to display these References on the Front End.

I want to be able to display these References on the MetaObject’s webpage.

What am I missing? All References have ‘Storefronts API access’.

Hi @madskatholm — yes it should be possible. If you have “active-draft” status enabled please ensure the metaobject is set to Active. Then your syntax would be something like:

  {% assign example = shop.metaobjects.sample_products.example %}
  {% for feature in example.features.value %}
    Feature: {{ feature.name }}
  {% endfor %}

Thank you for your reply, @rpenner. However, I can’t quite see how this code retrieves the fixed References found at the bottom of all MetaObjects (https://help.shopify.com/en/manual/custom-data/metaobjects/referencing-metaobjects).

Just like I can use, for example: {{ metaobject.system.id }}, {{ metaobject.system.handle }}, {{ metaobject.system.type }}, etc., to retrieve information about a MetaObject — is there a way to fetch the list of fixed References linked to each MetaObject?

For example: {{ metaobject.system.references.list }}

There is no known way to retrieve the references where a metaobject is used in Liquid at the moment. Your best bet is to loop over the ressource you’re looking for and constructing an array from this, here’s an example for articles:

{% liquid
  assign target_metaobject = metaobjects.type.handle

  assign reference_list = null
  paginate blogs.news.articles by blogs.news.articles_count
    for article in article_list
      assign article_metaobject = article.metafields.custom.target.value

      if article_metaobject == target_metaobject and reference_list == null
        assign reference_list = article | uniq
      elsif article_metaobject == target_metaobject 
        assign reference_list = article | uniq | concat: reference_list
      endif
    endfor
  endpaginate
%}

Using this code reference_list is now an array containing the list of articles using the metaobject. As you can see, it is not very efficient but does the job. However, note that you will limited to reference across the first 250 articles, the pagination doesn’t go further so for high article counts, you may miss some references.