Shopify themes, liquid, logos, and UX
How do I render out a Meta object string and image in a Custom Liquid code section on my product page?
I'm trying to make a "brand badge" for every product, to display what brand they are connected to but can not wrap my head around this.
Do you call it through metafield?
{{ product.metafields.custom.brandbadge }}
Or do you call it through metaobjects?
{{ shop.metaobjects.brand_object.name }}
And do you render out the content?
I have been looking at https://shopify.dev/docs/api/liquid/objects/metaobject but can not seam to understand it.
@mns-burg Hope you are doing well.
Metaobject is a global object so you have to use it like below:
{{ metaobject.title.value }}
Is that also the case if I want to show a metaobject on my product page using the "Custom Liquid" section?
I can not seam to get it to render/output anything.
@mns-burg yes you can. but you have to use your handle of metaobject to access in product page
Hello @mns-burg,
Certainly! To display a brand badge using metafields, use the following Liquid code:
<div class="brand-badge">{{ product.metafields.custom.brandbadge }}</div>
If you’re using metaobjects, replace the metafield reference with the appropriate metaobject field:
<div class="brand-badge">{{ shop.metaobjects['brand_object']['name'] }}</div>
Remember to adjust the class names and styling according to your theme.
Thanks!
How will I go around targeting the metaobject, that have been chosen in the individual products metafield.
I seam to get no output or a the text "MetaobjectDrop".
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024