Skip Navigation

[Gelöst] Check if page has parent and use it's featured image

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
How to dispaly parent post featured image conditionally

Solution:
you can use [wpv-conditional] shortcode to dispaly conditional output.

You can find proposed solution with the following reply:
https://toolset.com/forums/topic/check-if-page-has-parent-and-use-its-featured-image/#post-406904

Relevant Documentation:
https://toolset.com/documentation/views-shortcodes/#wpv-post-featured-image
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created vor 7 Jahre, 10 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 2 Antworten, has 2 Stimmen.

Last updated by David vor 7 Jahre, 10 Monate.

Assisted by: Minesh.

Author
Artikel
#406808

I am trying to test if a page's parent has a featured image and if so to use the parent's featured image. I expected either of the following code snippets to work but they aren't.

[wpv-conditional if="( '[wpv-post-featured-image id='$parent']' ne '' )"]
	[wpv-post-featured-image id='$parent' size='full' class='post-thumbnail']
[/wpv-conditional]

or...

[wpv-conditional if="( (empty('[wpv-post-featured-image id='$parent']')) )"]
	[wpv-post-featured-image id='$parent' size='full' class='post-thumbnail']
[/wpv-conditional]

I confirmed that the shortcode within the conditional does work on it's own but I've got something wrong with my conditional itself. Any help would be appreciated.

#406904

Minesh
Supporter

Languages: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

I've tested this and following code is working at my end. Could you please try to use following code:

[wpv-conditional if="( '[wpv-post-featured-image output='url' id='$parent']' ne '' )"]
[wpv-post-featured-image id='$parent' size='full' class='post-thumbnail']
[/wpv-conditional]

I've used "output" attribute.

More info:
https://toolset.com/documentation/views-shortcodes/#wpv-post-featured-image

#407122

Yes, that worked, thank you! I needed to pay more attention to the specific parameters for the featured image shortcode. Again, thank you!

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