Skip Navigation

[Resolved] Conditional view with

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

Problem:
The user would like to have an OR relation in a condition.

Solution:
You can use the user interface to create the conditions.
You can nest expression but you cannot use OR on values. OR/AND/etc. are used between expressions:

// wrong condition
[wpv-conditional if="( $(wpcf-statusbeskrivelse) eq '2' or '4' )"]
// correct condition
[wpv-conditional if="(  ($(wpcf-statusbeskrivelse) eq '2') or ($(wpcf-statusbeskrivelse) eq '4') )"]

Relevant Documentation:
- https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/
- https://toolset.com/wp-content/uploads/2019/02/view-connecting-conditions.png

This support ticket is created 4 years, 7 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by samuelH 4 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1582195

Hi,
I am using this code: [wpv-conditional if="( $(wpcf-statusbeskrivelse) eq '2' )"]

I would like to add another "or" condition to this. How should i make this statement?

This is my best guess: [wpv-conditional if="( $(wpcf-statusbeskrivelse) eq '2' or '4' )"]

I would like to display the div if the status is 2 or 4. If the status is 1 or 3, the div should not display.

#1582299

Hello and thank you for contacting the Toolset support.

Try the following:

[wpv-conditional if="(  ($(wpcf-statusbeskrivelse) eq '2') or ($(wpcf-statusbeskrivelse) eq '4') )"]

You can also build this condition with the user interface. Check this image https://toolset.com/wp-content/uploads/2019/02/view-connecting-conditions.png

Read more about it here https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/

#1582785

My issue is resolved now. Thank you!