When using Link > URL field, can I have a variable target?

Hi,

I have an ACF Repeater field set up with a link array. I’d like to call this into a Div I have setup as an <a> using the URL field so that the whole div is clickable. Is there any way to have a variable target? Some of the links go off-site and I’d like that to open in a blank page.

image

I tried putting this code that I’m using elsewhere, but it doesn’t work. Is there a better way to achieve this?

{{dc:looper:field key=“hot_button_link.url”}} target="{{dc:looper:field key=“hot_button_link.target”}}"

Thanks!

Hello @petitshoo,

Thanks for writing in!

You can run a Looper Provider Dynamic Content {{dc:acf:post_field field="hot_button_link"}} and use {{dc:looper:field key=“url”}} to display the URL and then {{dc:looper:field key=“target”}} for the link target.

Possible element structure:

Div - Looper Provider / Looper Consumer
    Button element

We’d love to know if this helps.

Here is how i have it currently set up:

Row > Looper Provider with Dynamic Content: {{dc:acf:post_field field=“hot_buttons”}}
Column
Div > Looper Consumer: Setup as a link by choosing the “a” designation and I am using the URL field to put in {{dc:looper:field key=“hot_button_link.url”}}
• Div-Icon Circle (with text calling in an icon)
• The Title

Where would I put the code for the target?

Thanks!
Jen

Hello Jen,

Provide me with your login details so I can check your ACF fields and your Looper setup. The link target should be added where you have set up the link.

Thank you in advance.

Thanks!! Secure note attached.

Hello Jen,

Your Link URL should only have the dynamic content: {{dc:looper:field key="hot_button_link.url"}}
image

You will have to add the target as a custom attribute instead.

Check your layout now.

That did it! Thanks so much!!

You are most welcome, @petitshoo

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.