Skip Navigation

[Resolved] Conditional for Parent Featured Image

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue is that the user wanted to get their parent post information, particularly the featured image.

Solution:
This can be done by having a look at the solution i've posted below.
https://toolset.com/forums/topic/conditional-for-parent-featured-image/#post-1197430

This support ticket is created 5 years, 10 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 2 replies, has 2 voices.

Last updated by toolset-dave 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1197316

Hello,

I am trying to set up conditional for Parent Featured Image in Post which belongs to Company (CPT). Displaying the image works OK:

{!{wpv-post-featured-image item="@novinka-spolecnosti.parent"}!}

, but the problem is with conditional. I followed this https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/#checking-if-a-post-has-a-featured-image and I have added the item which links to parent. Both conditionals don´t work:

[wpv-conditional if="( NOT(empty($(_thumbnail_id item='@novinka-spolecnosti.parent'))) )"]
Image
[/wpv-conditional]
or
[wpv-conditional if="( NOT(empty($(_thumbnail_id) item='@novinka-spolecnosti.parent')) )"]
Image
[/wpv-conditional]

What I am doing wrong?

#1197430

Shane
Supporter

Languages: English (English )

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

Hi Dave,

Thank you for getting in touch.

There is an issue with the getting the parent information like this when using our conditional code.

What I recommend that you do is to perform it like this.

[wpv-conditional if="( '{!{wpv-post-featured-image item="@novinka-spolecnosti.parent" output="url"}!}' ne '' )"]
Image
[/wpv-conditional]

Please try this and let me know the results.

Thanks,
Shane

#1197658

My issue is resolved now. Thank you!