References
Using metafields and metaobjects with dynamic sources
Metafields and Metaobjects allow you to display dynamic information on your online store. If you have a theme that supports metafields, then you can connect a metafield to a section or block in the theme editor.
For example, a candle seller might want to display burn times for each type of candle available. After setting up a product metafield for burn time, the seller can add a block for burn time to their product template and then connect it to the product metafield. After setting up a collection metafield for a page that lists burn times, the seller can add a block to their collection template and then connect it to the collection metafield.
Tip
This feature requires a theme that supports JSON templates. Refer to your theme documentation to find out whether your theme is compatible with dynamic theme settings. Learn more about custom data.
Caution
If you have a Shopify theme, then you can connect most metafields and metaobjects to your theme by using the theme editor. If you're using other themes, or if you want to add custom data types that your theme doesn't support, then you can edit your theme code or hire a Shopify Partner to help you. Learn more about hiring a Shopify Partner.
Not all sections support dynamic sources. Refer to your theme documentation for more information.
You can display dynamic information in your online store by adding sections or blocks that can use dynamic sources. Dynamic sources can be used in any template, section, or block that displays compatible resources (product, collection, page, blog and blog post). You need to add your metafield before you can connect it in your templates. Refer to Dynamic sources for more information about using metafields and metaobjects via dynamic sources in your theme.
After you complete the setup process, follow these steps to connect dynamic sources to blocks or settings in your theme:
Steps:
- From your Shopify admin, go to Online Store > Themes.
- Find the theme that you want to edit, and then click Customize.
- From the dropdown menu, select the template that contains the section that you want to edit.
- Click an existing section to load the content into the preview window and access the options available to you, or click + Add section.
- Click the dynamic source button and then connect a dynamic source:
- Click Save.
Dynamic source selector
The dynamic source selector can be used to easily connect the right dynamic source directly in the online store editor. The following are some key features of the selector:
- You can reference dynamic sources from various resources, where applicable. For instance, if you are connecting a setting to a block that is connected to both a product resource and a page resource, then you can specify if you want to search for metafields associated with either the product or the page resource. This dropdown is at the top of the dynamic source selector.
- Search and Filter: The Dynamic Source Selector provides a search and filter functionality that helps you quickly find the metafield you need.
- Category Metafields Selection: The selector enables you to choose category metafields. These are additional attributes that become available when you assign a product category to a product. Accessing these metafields allows you to connect dynamic sources to any relevant fields on the underlying attribute metaobject.