Skip Navigation

[Resolved] Conditional output in View based on index/row number

This support ticket is created 4 years, 4 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
- 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 2 voices.

Last updated by catherineR-2 4 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1415181

Hi,

What I'm trying to do: We have a Taxonomy view, where we want to show all the tiles in a 3x3 grid.

However, in the very first item, we want to show a "Show All" option, so the first row would have that and then 2 items from the query, whereas all the rest of the rows would have 3 items from the query.

I tried the follow code, but it's not working. It's showing 3 items, then 2 items on the 2nd row, then 1 item on the 3rd row, and also repeating titles. Any suggestions are appreciated:

<wpv-loop wrap="3" pad="true">

<!-- first row has 'all' option and 2 regular -->
[wpv-conditional if="( '[wpv-loop-index]' eq '1' )"]
<div class="row gf-podcast-row">
<div class="col-sm-4 gf-podcast-col">
[elementor-template id="3286360"]
</div>
[wpv-item index=1]
<div class="col-sm-4 gf-podcast-col">
[elementor-template id="3286359"]
</div>
[wpv-item index=2]
<div class="col-sm-4 gf-podcast-col">
[elementor-template id="3286359"]
</div>
</div>
[/wpv-conditional]

<!-- other rows are normal -->
[wpv-conditional if="( '[wpv-loop-index]' gte '3' )"]
[wpv-item index=1]
<div class="row gf-podcast-row">
<div class="col-sm-4 gf-podcast-col">
[elementor-template id="3286359"]
</div>
[wpv-item index=2]
<div class="col-sm-4 gf-podcast-col">
[elementor-template id="3286359"]
</div>
[wpv-item index=3]
<div class="col-sm-4 gf-podcast-col">
[elementor-template id="3286359"]
</div>
</div>
[/wpv-conditional]
</wpv-loop>

#1416285

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I do not know why you are using the [wpv-conditional if="( '[wpv-loop-index]' eq '1' )"] to check the current index as you can add the code that will be applied per index using the shortcode [wpv-item index=1].

More info:
=> https://toolset.com/documentation/user-guides/views/digging-into-view-outputs/#vmeta-wpv-loop-parameters

#1416681

Thanks for the link to the example. I never saw that concept, of using wpv-item “outside” the divs of the normal row to create a special ending element. It should work for me to create a special starting element in the first row.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.