Skip Navigation

[Resolved] Highlight top 10 posts

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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

Last updated by michaelP-16 7 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#508149

Hi there,
how can I hightlight the first 10 posts in my view. Looks like the green background color from resolved posts here in forum?

Kind Regards
Michael

#508184

Nigel
Supporter

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

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

Hi Michael

There is a slightly laborious way you can do this in your loop output section using the wpv-index shortcode to generate different output (i.e. add a class to a container) for the first iteration ([wpv-item index=1]) and the second iteration ([wpv-item index=2]) and the third iteration ([wpv-item index=3]) etc. (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-item).

A neater solution is just to add a CSS rule to style the first 10 items differently, so make sure you have some kind of container for each loop iteration (e.g. div with class="iteration"), then you should be able to add a CSS rule like this:

.iteration:nth-child(-n+10) {
    background-color: green;
}
#508212

Hi Nigel,
yes, thats it.
The simple css-solution works great.
I work for the first time with wp types and sometimes I make it difficult for myself.
But I think already now that I become a new fan of wp types 🙂

Thank you ffor your quick support.
Kind Regards
Michael

The forum ‘Types Community Support’ is closed to new topics and replies.