Skip Navigation

[Resolved] Showing featured image automatically not working properly

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

Problem:
How to check featured image is empty or not and based on that display conditional output

Solution:
You can use [wpv-conditional] shortcode to check feature image is empty or not.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/showing-featured-image-automatically-not-working-properly/#post-901484

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

This support ticket is created 6 years, 5 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 6 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#901353

Hi,
I have a CPT called "Persons" and another CPT called "Articles". the Persons CPT is a parent to the Articles CPT.

Some articles have featured images and some articles don't.

So I want to show the article featured image when there is one, but show the person's image when there is no featured image for the article.

I used the following code to show the parent featured image:

[wpv-post-featured-image size="medium" id="$person"]

However, I am trying now to show the article featured image when it is present.

so i modified the code to be like this:

[wpv-conditional if="( '[wpv-post-featured-image]' eq '' )"]
[wpv-post-featured-image size="medium" id="$person"]
[/wpv-conditional]

But when I upload a featured image to the article, nothing show up.

can you please help me fixing the conditional so that:
- when the article has a featured image, show it, or
- when there is no featured image, show the parent image.

thanks in advance.

#901484

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - could you please try to use following code. Is is the code you are looking for?

[wpv-conditional if="( '[wpv-post-featured-image]' ne '' )"]
           [wpv-post-featured-image size="medium"]
[/wpv-conditional]


[wpv-conditional if="( '[wpv-post-featured-image]' eq '' )"]
           [wpv-post-featured-image size="medium" id="$person"]
[/wpv-conditional]