Skip Navigation

[Resolved] How do I conditionally display the post title of a parent post

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by melS 6 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#913082

I have a type "event" which could be a child of either of two types: "individual" and "organisation"

I want to display a link to the page for that parent, but only one will exist.

I've tried simply:
<h3>[wpv-post-link id="$person"]<br />
[wpv-post-link id="$org"]</h3>

But this displays a link back to the current post for the "empty" parent as well as the correct link to parent.

How can I conditionally display the correct, non-empty parent link?

Thank you

#913084

Ah - found a conditional that works:

[wpv-conditional if="( $(_wpcf_belongs_person_id) ne '' )"]
<h3>[wpv-post-link id="$person"]</h3>
[/wpv-conditional]
[wpv-conditional if="( $(_wpcf_belongs_org_id) ne '' )"]
<h3>[wpv-post-link id="$org"]</h3>
[/wpv-conditional]

Is this still the correct way to do things with the new post relationships release? I setup the site before the new release and so not sure if I should be migrating my code in any way.

#913200

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mel,

To display the parent title you will need to do it in the format similar to below.

[wpv-post-title item="@manufacturer-car.parent"]

Where you will replace manufacturer-car with your parentslug-childslug.

Please let me know if this helps.

Thanks,
Shane

#913380

Maybe I wasn't very clear, I know how to display the parent title/link, but the parent could be one of two different types, so I only want to display the title of the existing parent (one will be null).

I've managed to get it to work using

[wpv-conditional if="( $(_wpcf_belongs_person_id) ne '' )"]
<h3>[wpv-post-link id="$person"]</h3>
[/wpv-conditional]
[wpv-conditional if="( $(_wpcf_belongs_org_id) ne '' )"]
<h3>[wpv-post-link id="$org"]</h3>
[/wpv-conditional]

But I'm not sure if this is best practise for the new post relationships in Types v3.0

Thanks!

#913465

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screen Shot 2018-06-14 at 8.55.07 AM.png

Hi Mel,

Actually this works and the conditional works.

However with Types 3.0 the calling of the parent information is using the old method.

What you need to do is to click the fields and types button and re-add the post title and then click on "Post Selection"

Then here you should be able to select the parent that you want to display the title for.

Please let me know if this helps.
Thanks,
Shane

#913948

OK thanks