Skip Navigation

[Resolved] View that returns the Post URL of the bi-directionally linked Post

This support ticket is created 5 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Waqar 5 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#1177439

Hi team,

I'm trying to understand if there's a way to dynamically generate Post URLs of bi-directionally linked CPTs?

Please see below for what I mean:

hidden link

Thanks so much.

#1177448

Hi Bill,

As discussed, I've set your next reply as private, so that you can share the temporary admin login details.

Please also share the link where the button element from your screencast can be accessed.
( hidden link )

regards,
Waqar

#1177464

Hi Bill,

Thank you for sharing the access details.

First, I noticed that in your view "Book ⟩ Appointment", you've added the "wpv-post-url" shortcode to call the URL of the child post from the "book-appointment" relationship:
( screenshot: hidden link )


[wpv-post-url item="@book-appointment.child"]

Since that content template is already for a loop in which information about the connected appointment exists, you only need to call current post's URL:


[wpv-post-url]

Once this is fixed, you'll note that the view's shortcode [wpv-view name="book-appointment"] will work correcly when used inside any text/content editor section.
( screenshot: hidden link )

As for using this shortcode inside a Beaver Builder plugin's button element, it seems it strips any " and ' characters used in the link field since that field is actually designed to only accept URL.

You can alternatively register a custom shortcode which doesn't accept any attribute and see if that works in that button's link field.

For example:


add_shortcode('show_conn_app_link', 'show_conn_app_link_fn');
function show_conn_app_link_fn($atts) {

	$output = do_shortcode('[wpv-view name="book-appointment"]');

	$stripped = preg_replace('/\s+/', ' ', $output);

	return str_replace(' ', '', $stripped);
	
}

The above custom shortcode function can be added into the active theme's "functions.php" file, which will get output from the same view and clean it from any extra/empty spaces.

You can then call it in the button's link field like this:


[show_conn_app_link]

I hope this helps and please let me know how it goes.

regards,
Waqar