How to extract URL from <a href=""> in Liquid

crusco
Tourist
10 0 3

I'm trying to use {{ product_type | url_for_type }} inside a <option value=""> but it returns a link <a href=""> tag.

is there a way to extract the URL from the href="" and return it inside the <option value=""> ?!

I've tried with strip_html but it doesn't work

{{ product_type | url_for_type }}
// Returns: <a href="/collections/all/video+night" title="video">video</a>

{{ product_type | url_for_type | strip_html }}
// Returns: "video" not what's inside href=""

 

Replies 2 (2)

g33kgirl
Shopify Partner
390 109 142

Hi @crusco, have you tried using:

{{ product.url}}
If you found my answer helpful, please LIKE and ACCEPT.
buymeacoffee.com/g33kgirl
If you're not comfortable with code, please modify code files at your own risk.

LitExtension
Shopify Partner
4860 1001 1128

Hi @crusco

Can you please share your store URL and take a screenshot of error? So I will check and provide a solution here. 

Greetings! 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify