Skip Navigation

[Resolved] Extra wpv-conditional output with the use of wpv-item index

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

Problem:
In the output of a View conditional shortcodes are being used to optionally display certain content, but seen on the front-end a [/wpv-conditional] closing tag erroneously appears.

Solution:
Client is also using the wpv-item shortcode to show different content for different iterations of the Loop.

The wpv-item shortcode is evaluated before the wpv-conditional shortcode, and so cannot be wrapped by a condition.

The conditional shortcode must come wholly after the relevant wpv-item shortcode.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-item
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

This support ticket is created 6 years, 6 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by randallH-3 6 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#951151
Screen Shot 2018-07-19 at 3.26.07 PM.png
[wpv-layout-start]
	[wpv-found-count]


	[wpv-items-found]
	<!-- wpv-loop-start -->
<wpv-loop>
[wpv-conditional if="( '[wpv-current-user info='login']' eq '[types field='note-user'][/types]' )"]
		[cred_form form='edit-note']
[/wpv-conditional]
  
  
[wpv-conditional if="( '[wpv-current-user info='login']' ne '[types field='note-user'][/types]' )"]
[wpv-item index=1]
		[cred_form form='add-note']

[/wpv-conditional]
</wpv-loop>

	<!-- wpv-loop-end -->

	[/wpv-items-found]
	[wpv-no-items-found]

		[cred_form form='add-note']

	[/wpv-no-items-found]


[wpv-layout-end]

Image is attached.

#951312

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You are splitting the wpv-conditional shortcode with the wpv-item shortcode.

You need to move the wpv-item shortcode before the wpv-conditional shortcode.

#951642

So it is not possible to use conditional with wpv-item?

#952116

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yes, you just need to move the whole of the conditional shortcode (opening and closing) after the wpv-item shortcode.

The wpv-item shortcode means "display what comes next for the nth iteration of the loop" and the way you have it only the closing wpv-conditional shortcode comes next.

#952143

Thanks!