How to add blog posts to product pages using metafields

DutchDelight
Excursionist
21 0 4

When I am in a Product template, I am able to add blog posts. Set quantities, pick the post, no problem.

However, I want to do this through metafields.

When I go to the blog posts, I see I can connect a dynamic source, but when clicking on this, I don't have anything.. which I understand, because I need to set those up.

However, when I create a metafield, I don't see a way to connect it to the blog posts. Am I missing something?

Replies 2 (2)

Xipirons
Shopify Partner
136 24 29

Hi @DutchDelight 

 

Based on the information provided in the search results, it seems that currently there is no direct way to link blog posts to products using metafields in Shopify.

 

A few key points:

 

1. Shopify's metafields allow adding custom fields to products, collections, orders, customers, etc. However, there is no built-in "blog post" metafield type that would allow directly linking a blog post.

 

2. When creating metafields, the option to reference or link to a specific blog post is not available in the metafield definition settings.

 

3. In March 2023, Shopify released the ability to use dynamic sources on blog posts and articles, allowing theme files to connect to metafields.However, this is for displaying custom metafield data on the blog post itself, not for linking the blog post to a product.

 

4. As a workaround, I would suggest:
- Creating a text metafield on the product to store the blog post's handle
- Adding a metafield to the blog post containing the product ID
- Then using Liquid code to loop through blog posts and render ones that match the product's stored blog handle or ID.

 

5. But there is no streamlined way to set this up directly through the Shopify admin metafield settings for products and blog posts.

 

In summary, the built-in metafields do not currently support a "blog post" reference type to easily link products and posts. The capability to connect dynamic sources to blog post templates is a recent addition, but does not address linking to products. Workarounds using Liquid code are possible but require more manual setup.

 

Was this helpful? Like or Accept solution - Buy me a coffee
- Contact me: Xipirons | WhatsApp
- Shopify Developer based in France, helping online merchants succeed

DutchDelight
Excursionist
21 0 4

Can't really accept it as a "Solution", but it does answer my question.. Too bad it isn't possible (yet).