Skip Navigation

[Resolved] wpv-conditional within another wpv-conditional ?

This support ticket is created 2 years, 10 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 2 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2297623

Hi,
is it possible to place an wpv-conditional argument within another wpv-conditional?

This is my present code:

[wpv-conditional if="(has_term('existing-team', 'neighbourhood-typ', null) eq '1')"]
[wpv-map-marker map_id="map-5" marker_icon="hidden link" marker_id='marker-[wpv-post-id]' marker_field="wpcf-anschrift" marker_title="[wpv-post-title output='sanitize']"]
<img src="[types field='header-image' width='600' url='true'][/types]" width='600' align='middle'/>
<h2>[wpv-post-title output="sanitize"]</h2>
<div style="font-size:16px;">
Neighbours: [types field='neighbours' output='raw'][/types]
Neighbourhood Type: [wpv-post-taxonomy type="neighbourhood-typ" format="name"]
City: [wpv-post-taxonomy type="city" format="name"]
Province: [wpv-post-taxonomy type="country" format="name"]
</div>
[/wpv-map-marker]
[/wpv-conditional]

I want to insert a condition that "Neighbours" are only shown if they have data:

[wpv–conditional if="('1' eq '1')"]Neighbours: [types field='neighbours' output='raw'][/types][/wpv–conditional]

I know I have to change the condition, but is it possible to insert an wpv-conditional argument within another wpv-conditional at all?

When I tried it showed the inserted argument as plain text.

Thank you for your help!
André

#2298541

Hello,

It is possible to use wpv-conditional within another wpv-conditional shortcode(nested wpv-conditional shortcodes).

But according to our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

When using very long content with the conditional shortcode you might encounter an error. Since Views uses native WordPress parsing for all shortcodes, this limitation does not come from the Views itself. In such cases, there is no alternative but to break up the content into smaller sections, which may mean having to repeat the conditional statements.

In order to avoid above issue, you can put the inner wpv-conditional shortcode into a content template, and display this content template with [wpv-post-body] shortcode.

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body