Skip Navigation

[Resolved] Possible to style first element of a view?

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

Problem:
How to style first element of a view results?

Solution:
You can achieve it using [wpv-item] shortcode in the Loop Output editor. Example screenshot here:
https://d7j863fr5jhrr.cloudfront.net/wp-content/uploads/2017/08/560896-wpv_item_index.png?x71388
This shows how to add “active” class on first slide only, you can do same for other slides (items) as well -- index=2, 3, 4, etc.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-item
https://toolset.com/documentation/user-guides/digging-into-view-outputs/
-- Specially take a look in section “Loop parameters & wpv-item : wrap, pad, pad-last, index”

This support ticket is created 6 years, 8 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by manuelE 6 years, 8 months ago.

Assisted by: Noman.

Author
Posts
#560692

Hi there,

Is it possible to address the first element of the "view-result" somehow different? Best would be a conditional output like "if first element" ...

I would need this because I´m creating a bootstrap slider in which the first element (=div) needs to have the class "active".

Thanks in advance!

Cheers,
Manuel

#560876

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Manuel,

Thank you for contacting Toolset support. Our forum is loaded with more tickets than usual. I am working on your ticket right now, trying to reproduce this issue and I believe this should be doable for Slider View. I will update you shortly with the result.

Thank you for waiting.

#560882

Hi Noman,

thanks for your answer ... and no worries, chances are that I found a solution, not sure yet but I will know within the next 2-3 hours or so ... will update you tonight if I need your help, otherwise I will mark this ticket as solved.

Bye for now,
Manuel

#560896

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

wpv-item index.png

I have tested this case, you can achieve it using [wpv-item] shortcode in the Loop Output editor. See attached screenshot for an example on how to add “active” class on first slide only, you can do same for other slides (items) as well -- index=2, 3, 4, etc.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-item

More info in this doc for understanding how Views Loop Output works:
https://toolset.com/documentation/user-guides/digging-into-view-outputs/
-- Specially take a look in section “Loop parameters & wpv-item : wrap, pad, pad-last, index”

I hope it helps, Thank you

#561057

Hi Noman,

thanks so much for looking into this!

Since I am using further conditional output in the view itself the approach with [wpv-item] was not working though (because this way the first element is not neccessarily index=1).

But: I completely started from scratch with the Views built in Slider and rebuild it for that. And it works just fine now! 🙂

Thanks again!
Manuel

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