Skip Navigation

[Resuelto] Open link to related post in new window using wpv-post-link

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I have a View that shows posts from post type A. I would like to include a link to related post type B, and I would like for the link to open in a new window/tab.

Solution: Build a link manually in HTML using the target attribute to open in a new window. Use the item attribute in wpv-post-url and wpv-post-title shortcodes to insert information about a related post.

<a href="[wpv-post-url item='@occupier.parent']" target="_blank">[wpv-post-title item="@occupier.parent"]</a>

Relevant Documentation: https://toolset.com/documentation/user-guides/views/views-shortcodes/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

This support ticket is created hace 3 años, 9 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 4 respuestas, has 2 mensajes.

Last updated by leilaG hace 3 años, 9 meses.

Assisted by: Christian Cox.

Autor
Mensajes
#1708051

Hi, trying to get wpv-post-link item to open in a new window in VIEW results, have tried the below code but it's not working

<a href="[wpv-post-url]" target="_blank">[wpv-post-link item="@occupier.parent"]</a>

#1708111

Hello, the wpv-post-link shortcode creates the link tag for you, so you're essentially wrapping the link in another link when you place wpv-post-link inside another link tag. That produces invalid HTML. If you want to create your own link tag manually in HTML to insert a target attribute, then you should use the wpv-post-title shortcode instead of the wpv-post-link shortcode inside the link tag. The syntax you are looking for is like this:

<a href="[wpv-post-url]" target="_blank">[wpv-post-title]</a>

However, I can see you have @occupier.parent in your wpv-post-link shortcode. Are you trying to link to a related post from a post reference field or post relationship, and show the related post's title in the link text?

#1708491

Hi Christian, yes that's the syntax we copied from. The link is working just not opening in a new window.

It's a post relationship but I think we may have unnecessarily doubled up and used a post reference too, as the bulk import we did, didn't seem to connect the relationship without the post reference and also the VIEW option for liking the post title of the post relationship was grayed out too.

#1709023

I see, so you'll need to add the item attribute to the URL shortcode as well as the title shortcode:

<a href="[wpv-post-url item="@occupier.parent"]" target="_blank">[wpv-post-title item="@occupier.parent"]</a>

Does that work correctly now?

#1709745

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.