I created a new metaobject since none of the listed store areas like Products, variants and so on in Shopify admin fit my requirement. The metaobject I created contains two fields as seen in the image below.
I want to know how to read these fields in header.liquid.
I need to change site’s header logo often and want to make it automated with a cronjob that runs on a different server that populates these fields once a day with the logo file name.
To read the fields from your custom metaobject in the header.liquid file, you’ll need to use Shopify’s Liquid language and access the metafields associated with the current shop.
Here’s an example of how you can retrieve and display the values of the custom metaobject fields in your header:
{% assign shop_metaobject = shop.metafields.custom.my_metaobject_key %}
{% if shop_metaobject %}
{% assign logo_file_name = shop_metaobject.logo_file_name %}
{% assign logo_alt_text = shop_metaobject.logo_alt_text %}
{% endif %}
Thank you. Can you tell me what is difference between metaobject and metafields as I see them both in Shopify admin?