How can I display a Metaobject field in a blog template?

In Shopify, I have created a metafield definition in “Blog posts” with the namespace and key “custom.designer”.

In this metafield, I have selected a Metaobject with the reference “creatives”, and in this Metaobject I have a single text field with the key “creatives.designer”.

Can someone help me, how to display the field from the Metaobject in a Blog template?

I have tried with the following, but I haven’t succeeded yet:

{% for article in blog.articles %}
  <h2>{{ article.title }}</h2>

  <!-- Accessing the Metafield -->
  {% assign customDesignerMetafield = article.metafields.custom.designer %}

  <!-- Accessing the Metaobject -->
  {% assign creativesMetaobject = customDesignerMetafield.creatives %}

  <!-- Accessing the Text Field in the Metaobject -->
  {% assign designerField = creativesMetaobject.designer %}

  <!-- Displaying the Text Field Content -->
  <p>Designer: {{ designerField }}</p>
{% endfor %}

Hi @matsbeckman

Kindly check if you’re looking something like this

So, you should do it like below

{% for article in blog.articles %}
  ## {{ article.title }}

  
  {% assign customDesignerMetafield = blog.metafields.custom.designer %}

  
  

Designer: {{ customDesignerMetafield }}

{% endfor %}

Let me know if this works for you.

Thanks

Sheesh B

Hi @Sheesh_b ,
Thanks for your reply,

It doesn’t seem to work for me unfortunately.

Long story short. I want to display designers name, from a blog post, on a blog list in the blog template. The designers name is mentioned in a Metaobject field on a blog post, and I want to display this name on a blog posts grid like the example below:

To get the value from each designer (Metaobject) I have made the following metafield in the blog post custom data:

Hope this make sense.

Hi @matsbeckman

You can try below code in case:

{% for article in blog.articles %}
  ## {{ article.title }}

  
  {% assign customDesignerMetafield = article.metafields.custom.designer %}

  
  

Designer: {{ customDesignerMetafield }}

{% endfor %}

Hi @Sheesh_b

I get the reference “Designer: gid://shopify/Metaobject/57854722385” when using your solution.

Do you know how to translate this to the real value?

Hi @matsbeckman

Can you share your store access in private message to work on this better as I’m not getting what you’re doing at your side to check it better.

Thanks

Sheesh B

Hi @Sheesh_b

I have sent you a private message.

Thanks