Help Metafield for Videos - Specific Products (Horizon Theme)

Been trying to create a Metafield to show YouTube videos link or embed, to only specific products. I’ve tried multiple types (single, multi line, rich) neither work when i link the metafield to a product.

i see most solved cases showing adding a code in Theme liquid.. I do not have a THEME.liquid in my code files.. Theme: Horizon. Please help..

Metafield name is custom.product_video

What type to have it , what code to input and where?

Hi @Mike510,

Step 1: Create the Metafield:

First, we need to create a metafield definition for your products.

  • Go to your Shopify Admin and navigate to Settings > Custom data.

  • Select Products, then click on Add definition.

  • For the “Name”, enter “Product Video”.

  • The “Namespace and key” should be custom.product_video.

  • For the “Select type”, choose Multi-line text.

  • Click Save.

Step 2: Add the Video Embed Code to a Product:

Now you can add a video to any product you want.

  • Go to Products in your Shopify admin and select the product you want to add the video to.

  • Scroll down to the Metafields section at the bottom of the page.

  • You will see the “Product Video” metafield you just created. Click inside the empty field.

  • Go to the YouTube video you want to use, click on Share, and then select Embed. Copy the entire HTML embed code.

  • Paste this embed code into the “Product Video” metafield on your product page in Shopify.

  • Click Save.

Step 3: Display the Video on Your Product Page:

Finally, let’s make the video appear on your live store.

  • From your Shopify admin, go to Online Store > Themes.

  • On your Horizon theme, click the Customize button.

  • Using the dropdown menu at the top of the page, navigate to Products > Default product.

  • On the left-hand sidebar, under the “Product information” section, click on Add block and choose Custom Liquid.

  • A new “Custom Liquid” block will be added to your product page template. In the code box for this block, paste the following line:
    {{ product.metafields.custom.product_video.value }}

  • You can now drag and drop the “Custom Liquid” block to position the video wherever you would like it to appear on the page (e.g., under the product description).

  • Click Save in the top right corner.

Now, the video will automatically appear on any product where you have added the embed code to the metafield.

Thanks!

1 Like

WOW !! Thank you so much! It’s been 3 days seeing over complicated answers, until this!!

question is there a way instead of a single video, to display a carousel of videos? Swipable?

I used to use Cozy Video Gallery app that would have you embed this code on a Product page

Would that work ? Will try or any other way?

I just tried adding a second video duplicating the metafield and liquid on theme editor but changed the name. Only shows one.

Thank you again for this it worked great ! now I have 2 different questions if its possible to do.

1) Use an embed code for a video carousel app I have on my shopify

instead of a single YouTube single video - will something like this code below be possible?

2) If above is not possible, is there a way to add two YouTube videos, so 2 different metafields?

With 1 metafield (custom.product_video) + linking it to a product + adding this CSS Liquid on the Theme builder default product {{ product.metafields.custom.product_video.value }} works ok

I tried creating another metafield “custom.product_video_2” and adding another CSS liquid {{ product.metafields.custom.product_video.value_2}} but only the prev 1 appears.

Hi @Mike510,

You were very close to solving this. The issue was a small typo in the Liquid code you tried for the second video.
Here is the corrected approach:

Step 1: Create a Second Metafield
Go to Settings > Custom data > Products.
Click Add definition.
Name: Product Video 2
Namespace and key: custom.product_video_2 (This needs to be unique).
Type: Multi-line text.
Click Save.

Step 2: Add the Second Video’s Embed Code to Your Product
Go to the product page in your Shopify admin.
In the Metafields section, you will now see “Product Video” and “Product Video 2”.
Paste the YouTube embed code for your second video into the “Product Video 2” field.
Click Save.

Step 3: Add a Second “Custom Liquid” Block
Go to Online Store > Themes and click Customize on your Horizon theme.
Navigate to your default product page (Products > Default product).
In the left-hand sidebar, click Add block and choose Custom Liquid.
In the code box for this new block, paste the following code. Notice the key product_video_2 matches your second metafield.

{{ product.metafields.custom.product_video_2.value }}

Drag this new “Custom Liquid” block to where you want the second video to appear.
Click Save.

The product page will now display both videos, each sourced from its own metafield.

Thank you!

1 Like

You’re the best! thank you !!

So that works with single videos only, no solution for carousel right? like adding this from a shopify installed app.

example:

@Mike510,

Please mark my comment as Solution.

Thank you!

Yes marked thank you!