Metafields list of values for related pages

Hi, I am trying to show a list of pages related to the product, and make them appear as a link to the page itself.

At the moment I can show the page information if the metafield is not setup as a list

This works for a single page reference

{{product.metafields.my_fields.dictionary | metafield_tag}}

But if I try with a metafield that has been setup to handle multiple items, nothing appear.

I also tried this but didn’t work:

{% for related_product in product.metafields.my_fields.dictionary.value %}
{{product.metafields.my_fields.dictionary_term | metafield_tag}}
{% endfor %}

Any ideas of where the issue could be?

Thanks so much, I am quite new to liquid language

max

Hi @maxdelvita ,

Try this instead. Make sure you are calling this inside a file that already have a product object

{% for related_product in product.metafields.my_fields.dictionary.value %}
{{ related_product.title }}
{% endfor %}

I have tried but it doesn’t work.

Let me clarify. The metafield is a type: reference, and it’s for pages.

I tried with "{% for related_page " instead of “related_product” but also doesn’t work

Here the entire code:

{% for related_page in product.metafields.my_fields.dictionary.value %}

{{ related_page.title }}

{% endfor %}

Oh your calling this in the page? Therefore, you have to have product. What parameter are you using to call the product?

@made4Uo another clarification, I tried with a metafield “Product (List)” and it works perfectly, but not with a metafield that is a “Page (List)”

Max

No, I am calling this from a product page.

But what I want to show is a list of pages.

This metafield is a Reference field, for pages, which accept a list of values. Hope it clarifies

Sorry if it might be a bit confusing, let me try to clarify again.

  • I have a product page
  • In this product page I want to show a list of pages I have created, that contain explanation of certain terms related to the product I am selling
  • In order to do this I have created a product metafield which is a “reference” type, and the reference is for “Page”, and I have also selected the ability to accept a list of values
  • In this way, for each of my products I can define a list of pages connected to it
  • Now I want to show a list of these pages with Title and Url, in my product page

This is an example of how it should look like

I have the same conondrum. I want the product cards to show a couple of metafield lists, but I also want those values to link to a page with all other products having that value. So if a customer is viewing a product for ‘dry skin’, this value is shown below the product i the metafield list displaying categories, BUT- as a link, so the customer can click it and see all other products for dry skin.

It’s sort of what you dried here isn’t it? Did you ever figure out how to do it?