Skip Navigation

[Waiting for user confirmation] Conditional inside a view doesn’t work

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)

Tagged: 

This topic contains 9 replies, has 1 voice.

Last updated by Minesh 12 hours, 16 minutes ago.

Assisted by: Minesh.

Author
Posts
#2813210
Captura de pantalla 2025-06-19 a las 17.24.28.png
Captura de pantalla 2025-06-19 a las 17.23.33.png

I need to use a conditional, using a field, inside a view. I'm in content template, and this view is about a related custom post. Template is for "places", and view is for "venues" in this places. I try to use a condition on the venue's view. "If a field is 1", show this. As I don't have "else", I also use NOT "If a field is 1", to show another thing. But second condition is always true.

1st condtion
( ( '[wpv-post-field name="llum-natural" ]' eq '1' ) )

2nd condition
NOT ( ( '[wpv-post-field name="llum-natural" ]' eq '1' ) )

I attach an example with debug activated.
Thank you

#2813266

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Instead of using the NOT with your condition.

As I understand, you want to display something else when field is not set or it does not have value equal to 1.

What if you adjust the condition as given under with your conditional shortcode.

( '[wpv-post-field name="llum-natural" ]' eq '' )

Does that helps?

#2813271
Captura de pantalla 2025-06-20 a las 8.20.22.png

Hi!
I've changed the condition following your idea, but it doesn't work. In the second conditional, field is not used:

####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' = '' )
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: ( '' = '' )
--------------------

This is the debug information.
Thank you!

#2813290

Minesh
Supporter

Languages: English (English )

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

I'm not sure why field is not used for you.

What exactly you want.

You want to display something when field value is equal to 1.

And now, you want to display something else when field value is empty?

Can you please share problem URL where with what post I can test the conditoin against and also share your exact requirement.

#2813293

Hi,
there is a field called llum-solar that indicates if a venue has natural sunlight or not. If the field is '1', I need to show venue's name followed by a sun icon. If not, just the name. As I can't use a "else", I've created two conditions, one for field = 1, and one for not(field = 1), or now field=''. This second condition is the one is not working.

If you look a this url

hidden link

you can see there are some venues with sunlight, and other without. The ones with sunlight show the name twice, because second condition is always true.

Thanks!!

#2813296

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've adjusted the codnitional statement as given under:

( ( '[wpv-post-field name="wpcf-llum-natural" ]' eq '' ) ) 

Can you please check now and confirm it works as expected.

#2813601

Hi,
it works as expected, in Catalan. But it doesn't work in Spanish or English.

hidden link

But also, I don't know why it works in Catalan... This is the same I tried before using 'NOT'.

Thanks!

#2813615

Minesh
Supporter

Languages: English (English )

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

Ahh - I see you are using WPML.

Have you checked the following Docs:
- https://toolset.com/course-lesson/how-to-prepare-the-site-to-run-multilingual/
- https://toolset.com/course-lesson/translating-views-content-templates-archives-and-forms/

I see you are using cache as well - Please try to delete the cache and check.

If your issue still persists - what if you try to use the conditional shortcode instead of conditional block. You can add the following conditional shortcodes by adding shortcode block to your content template

[wpv-conditional if="( '[types field='llum-natural' output='raw'][/types]' eq '1' )"]
  your code goes here
[/wpv-conditional]

[wpv-conditional if="( '[types field='llum-natural' output='raw'][/types]' eq '' )"]
  your code goes here
[/wpv-conditional]

#2813618

Christopher Amirian
Supporter

Languages: English (English )

Hi,

This is Christopher following up on the issue. Would you please check that the field itself is not translated? If so then the conditional will not work.

And usually the page that the view is used should be refreshed:

- Go to your Dashboard > Pages.
- Open the edit screen of the original page. You should see a pencil/circle/gear icon in the sidebar options under the "Languages" section.
- Make a small change, for example, add an extra blank space at the end of a sentence/paragraph.
- Save it.
- You should now see that a circular arrow appears beside the 2nd languages links, this means that an update is required.
- Edit the translation again and save it up to 100% translated.

Also I could not find the aection in the page that you use dthe conditional can you give some screenshots?

Thanks.

#2813916

Minesh
Supporter

Languages: English (English )

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