Skip Navigation

[Resolved] Conditional display based on parent custom fields

This support ticket is created 3 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1637891

Tell us what you are trying to do?

I am trying to display a button only if the parent post has a custom field that is checked. I have a parent post type called "fairs" and a child post type called "booths". When the parent post type "fairs" has the custom field "Turn video chat buttons on" is checked, I want the button in the booth content template to be displayed.

Is there a similar example that we can see?

I am currently trying this out on this post: hidden link

The code I have for this conditional logic is :
[wpv-conditional if="( $(wpcf-turn-video-chat-buttons-on) eq '' )" evaluate="false"]
<a class="size-full booth-button talk-to-employer" href="hidden link field='anymeeting-link' output='raw'][/types]" target="_blank" rel="noopener">
<img src="hidden link" alt="Talk to the employer button" width="347" height="76" class="size-full"/></a>
[/wpv-conditional]

Currently, the button does not display even if the custom field "Turn video chat buttons on" is checked. Howe can I change the code in the conditional to make this work?

What is the link to your site?
hidden link

#1638359

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can use the [wpv-conditional] shortcode in conjunction with the Types shortcode that query the parent field value using the item attribute.

For example - can you please try to use the following code:

[wpv-conditional if="( '[types field="turn-video-chat-buttons-on" item="@relationship-slug.parent"][/types] ' ne '' )"]

   <a class="size-full booth-button talk-to-employer" href="<em><u>hidden link</u></em> field='anymeeting-link' output='raw'][/types]" target="_blank" rel="noopener">
<img src="<em><u>hidden link</u></em>" alt="Talk to the employer button" width="347" height="76" class="size-full"/></a>

  [/wpv-conditional]

Where:
- replace relationship-slug with your original post-relationship slug.

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