How to show a metafield "related_blog_post" on product page?

How to show a metafield "related_blog_post" on product page?

CrazyGen_IN
Tourist
12 0 4

I created a metafield "related_blog_post" which contains URL of related blog post to that product, I want to show that on product page.

Either by block, button or text, through which we can jump to related blog post...

 

www.crazygen.in 

Replies 3 (3)

Kyle_liu
Shopify Partner
183 27 31

Hi @CrazyGen_IN 

 

1、

Kyle_liu_0-1726813086616.png

2、

Kyle_liu_1-1726813138612.png

3、

Kyle_liu_2-1726813181258.png

 

<div style="text-transform: uppercase;">
                  {%- if product.metafields.custom.related_blog_post != blank -%}
                    {% assign metaobject_data = product.metafields.custom.related_blog_post.value %}
                    {% if metaobject_data %}
                      <p><a href="{{ metaobject_data }}">Product Introduction</a></p>
                    {% endif %}
                  {% endif %}
                </div>

 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me on ([email protected])

namphan
Shopify Partner
1330 164 199

Hi @CrazyGen_IN,

Please go to Customize > Product information > Add block > Custom Liquid and add code:

Screenshot.png

Code:

<a href="{{ product.metafields.custom.related_blog_post }}">Link blog</a>
Coffee tips fuels my dedication.
Shopify Development Service
Need help with your store? [email protected]

Vinsinfo
Shopify Partner
427 143 143

@CrazyGen_IN Please follow below steps to show the metafield "related_blog_post" on product page.

 
1. From admin go to "Online Store" -> "Themes".
2. Click "Customize" button form the current theme.
3. Go to product page.
4. Click add block under the product information section and select the "Custom Liquid" block.
Vinsinfo_6-1726913420237.png

 

5. Paste the below code in the custom liquid section as like below screenshot.

 

<div class= "metafield_value">
  <a href="{{ product.metafields.custom.related_blog_post.value }}" class="related_blog_post_btn">
    See blog
  </a>
</div>
<style>
  .product__info-wrapper .metafield_value .related_blog_post_btn {
    padding: 7px 12px;
    background-color: #000;
    color: #ffffff;
    border: solid 1px #000000;
    text-decoration: none;
    border-radius: 2px;
    font-size: 17px;
    display: flex;
    justify-content: center;
  }
</style>

 

Vinsinfo_7-1726913462844.png

 

FYI: If you are using multiple product templates, you need to add the custom liquid block in all the templates.
 
6. Result will be,
Vinsinfo_8-1726913590164.png

 

 

Please provide your support by click "Like" and "Accepted" if our solution works for you. Thanks for your support.
Please reach out to [email protected] for any enquires related to Shopify.
Our Services: Custom Theme Development, Theme Customization, Custom Feature Implementation, Data Migration, Custom APP Development, Website Optimization and Google Merchant Center Support