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.
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
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:
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:
I hope this helps and please let me know how it goes.
regards,
Waqar