Skip Navigation

[Resolved] Conditional Display of Content Within a View

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 2 replies, has 1 voice.

Last updated by - 1 week, 5 days ago.

Assisted by: Minesh.

Author
Posts
#2881103

Tell us what you are trying to do?

I have a custom taxonomy type called "guests". I am able to properly display the content for a particular post using this shortcode: [wpv-post-taxonomy type="guests"]
The problem is that there are a few cases in which I have no guests, and a few other cases where the number of guests is too high, so the display looks bad.
I want to create an appropriate conditional display as follows:
If the count of "guests" is 0, then display "Nobody",
else if the count of "guests" > 3, then display "Multiple",
else display the full comma separated list of "guests".

Is there any documentation that you are following?

Your documentation on conditional shortcodes is NON-EXISTENT--I know it used to be there, but I can no longer find it, no matter what search terms I try.

Is there a similar example that we can see?
No.

What is the link to your site?
hidden link
You can see an example of bad display here: hidden link (there are too many guests listed in the first item on the page).

#2881436

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 code and check if that helps:

[wpv-conditional if="( '[wpv-post-taxonomy type="guests" format="count"]' = '0' )"]
Nobody
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-taxonomy type="guests" format="count"]' > '3' )"]
Multiple
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-taxonomy type="guests" format="count"]' > '0' AND '[wpv-post-taxonomy type="guests" format="count"]' <= '3' )"]
[wpv-post-taxonomy type="guests" separator=", "]
[/wpv-conditional]

And here is a Doc for legacy views:
- https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/
- https://toolset.com/documentation/legacy-features/views-plugin/#conditional-output-in-views

#2881558

Yes, that seems to work fine, thank you.
David