Skip Navigation

[Closed] Pass parent post's custom field URL to child's button via shortcode

This support ticket is created 7 years, 3 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 7 years, 3 months ago.

Assigned support staff: Beda.

Author
Posts
#331089

I'm trying to display a parent post's url in a child's view. I use the following code:

<a href="[types field='link-to-album-page' id='$album'][/types]" class="button" >VIEW ALBUM</a>

It doesn't work. The URL gets displayed as an unformatted text instead of becoming the url for the href.
Strangely, I have a couple of other problems:
The parent's featured image (thumbnail) cannot be passed over to the child with shortcode, however, a new custom image property can. Why is that?
I also need to pass on the parent post's title, but I can't do that either.

Here's the entire view's conditional part that displays the Song custom post type:

[wpv-conditional if="( '[wpv-post-type]' eq 'song' )"]
<div class="slider-content">
  <div id="post-image">
    [types field="cover-image" size="thumbnail" align="none" resize="proportional" id="$album"][/types]
  </div>
  <div id="post-meta">
    <div id="texts">
	    <h2 id="post-title">[wpv-post-title]</h2>
    	<p id="post-author">[types field='post-title' id='$album'][/types]</p>
    </div>
    <a href="[types field='link-to-album-page' id='$album'][/types]" class="button" >VIEW ALBUM</a>
  </div>
</div>
[/wpv-conditional]

Why doesn't it display parent data? Parent post type is "album".
Thanks.

#331235

Thank you for contacting us here in the Support Forum

I will take care of your ticket.
Could you please share your Debug Informations with me?
https://toolset.com/faq/provide-debug-information-faster-support/

It could be that you haven't updated all Plugins and WordPress, which would explain part of the issues.

To use a Types URL field in a Button href link, I suggest to go with RAW output and not formatted, as this:

<a href="[types field="test-url" output="raw" id="$parent"][/types]" class="btn btn-info" role="button">Link Button</a>

Every Field of a Parent Post can be adde fusing a $parent ID attribute, as in tho example for Featured Image:

[wpv-post-featured-image id="$parent"]

Please don't hesitate to inform me in case the issue persists

Thank you for your patience.

The topic ‘[Closed] Pass parent post's custom field URL to child's button via shortcode’ is closed to new replies.