Skip Navigation

[Resolved] wpv-conditional not working

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 7 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2698209

I have a custom image term field for the taxonomy "Cities" where I upload an image I want to show on the city archive page. IF the city has an image, I want to display that image on the page. IF a city does NOT have an image uploaded, I want to display a default image.

The following code properly displays an image, IF the city has an image: [wpv-taxonomy-field name='wpcf-background-image']

SO, i figured the following WPV-CONDITIONAL would evaluate whether or not there was an image attached:

IF Empty (False) - [wpv-conditional if="( empty($(wpcf-background-image)) )"] ...url of default image here... [/wpv-conditional]
IF Attached (True) - [wpv-conditional if="( $(wpcf-background-image) )"] [wpv-taxonomy-field name='wpcf-background-image'] [/wpv-conditional]

BUT, it doesn't work. I found a note from Nigel in another thread that images cannot be properly evaluated...SO, I added a check box termfield called "background-uploaded" and I tried using that to evaluate. Since checked box has a value of "1", and unchecked would be blank, I tried the following:

[wpv-conditional if="( $(wpcf-background-uploaded) eq '1' )"] [wpv-taxonomy-field name='wpcf-background-image'] [/wpv-conditional]

Doesn't work...

I also tried:

[wpv-conditional if="( $(wpcf-background-uploaded) eq '0' )"] ...default image url... [/wpv-conditional]

and...

[wpv-conditional if="( $(wpcf-background-uploaded) eq '' )"] ...default image url... [/wpv-conditional]

Also doens't work.

FINALLY, I tried this, but the nested shortcode gave an error. SO, i added the "wpv-taxonomy-field" shortcode in the Toolset frontend settings to allow nesting, but it still didn't work.

[wpv-conditional if=" '[wpv-taxonomy-field name='wpcf-background-uploaded']' eq '0' "] It's EMPTY [/wpv-conditional]

ANY IDEAS?

#2698360

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

What if you try to use the following conditional method:

[wpv-conditional if="( '[types termmeta='background-image' output='raw'][/types]' ne '' )"]
<p> Image is available so display the image </p>
[types termmeta='background-image'][/types]
[/wpv-conditional]

[wpv-conditional if="( '[types termmeta='background-image' output='raw'][/types]' eq '' )"]
<p>There is no image - so display here default image </p>
[/wpv-conditional]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/