Skip Navigation

[Resolved] URL field to open in a new tab

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a link that opens in a new tab, using the URL from a custom field. When I add target="_blank" to the custom field, the link does not open in a new tab.

Solution: Add target="_blank" to a link tag, then use the raw URL field as the link's href attribute.

<a class='w-btn style_solid color_primary icon_none standard-button' href="[types field="newsletter-url" output="raw"][/types]" target="_blank">View Newsletter</a><br>

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#url

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by digitalF 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#915854

Hi,

I have a view snippet as follows:

View Newsletter<br>

I have a custom field for a url field. The only issue is getting the link top open in a new tab, as this opens in the same window. Unfortunately adding target="_blank" doesn't work.

Many thanks,

Nathan

#915969

Hi, where are you adding target="_blank" - in the Types field shortcode or in the link tag? If you add the target attribute to the link tag, it should work:

<a class='w-btn style_solid color_primary icon_none standard-button' href="[types field="newsletter-url" output="raw"][/types]" target="_blank">View Newsletter</a><br>

If you add it to the Types field shortcode, it will not have any effect because the raw output attribute overrides it and only outputs the URL.

#916170

Ah, perfect - that worked a charm!

Many thanks!

Nathan