We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Making a button URL that uses a metafield open in new tab

Solved

Making a button URL that uses a metafield open in new tab

Franrulzok
Tourist
27 0 1

Hi, I am using Woodstock theme.

 

On a product template, I'm using the promotions card section that pulls a URL from a product metafield to populate the CTA. Not all products have them but this one does.

Screenshot 2024-12-11 140311.png

The metafield URLs are links to files that sit inside Shopify, so not technically an external link I don't think. I'd love these buttons to open in a new tab but I can't figure out how to do that. 

 

Any help would be great! Thanks

Accepted Solution (1)
Shadab_dev
Shopify Partner
1583 83 173

This is an accepted solution.

This is what it will look like

Shadab_dev_0-1733887876240.png

 

You are using a paid theme so to tell you the exact file or see it myself i will need access. If it was a free theme by shopify i could have told you the file name. You can check for file names like multi-column.liquid that renders the molticolumn section

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.

View solution in original post

Replies 10 (10)

Shadab_dev
Shopify Partner
1583 83 173

This is simple. Just open your code editor and open the file that is rendering the buttons. The button are a tag, inside the a tag just add this attribute target="blank". This will open the file on a new tab

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.
Franrulzok
Tourist
27 0 1

Thanks, I'm not a pro with coding. Do you mind providing a bit more info on where I would find the file with buttons in it? And what the button tag looks like?

Shadab_dev
Shopify Partner
1583 83 173

This is an accepted solution.

This is what it will look like

Shadab_dev_0-1733887876240.png

 

You are using a paid theme so to tell you the exact file or see it myself i will need access. If it was a free theme by shopify i could have told you the file name. You can check for file names like multi-column.liquid that renders the molticolumn section

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.
Franrulzok
Tourist
27 0 1

I found the multicolumn.liquid but that code you've copied isn't in there. If I search button, many instances come up but not that specific code.

Shadab_dev
Shopify Partner
1583 83 173

Try searching with the class name with ctrl + f. Click inside the code editor and press ctrl + f a search bar will appear down below then paste this multicolumn-card__link.

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.
Emm_
Shopify Partner
9 0 10

Thank you @Shadab_dev, that helped me when I was trying to achieve the same thing!

 
Shadab_dev
Shopify Partner
1583 83 173

Great to hear that. Its interesting how you can reach multiple people from a single post 😊

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.

DaisyVo
Shopify Partner
4469 501 598

Hi @Franrulzok 

 

I hope you are well.

 

When clicking on a link to open it in a new tab, the <a> tag should include the attribute target="_blank", like this: Example screenshot.

 

For instance, in this case, the <a> tag does not have the target="_blank" attribute: Example screenshot. As a result, clicking the link redirects the user to the current tab instead of opening a new one.

 

You should find <a> tag and adjust target="_blank"then it will work properly. 

 

Please let me know if it works. Thank you!

 

Best,
Daisy - Avada Support Team.

 

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution
Franrulzok
Tourist
27 0 1

So I'm not coding in a URL, otherwise this solution would work. I'm adding a URL to a product metafield and the section on the product page is populated based on the metafield. 

 

Any other ideas on how to acheive this?

DaisyVo
Shopify Partner
4469 501 598

Hi @Franrulzok 

 

Could you please share the screenshot of the code you are referring to? And also the meta field setting from your end. 

 

Thank you so much!

 

Best,

Daisy - Avada Support Team. 

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution