Skip Navigation

[Resolved] Adding a CSS class name to [wpv-view] shortcode

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

Problem:

The issue here is that the user wanted to add a css attribute to our Views shortcode.
Solution:
Unfortunately no you won't be able to pass a class attribute to our Toolset view.

My recommendation here is that you wrap the view shortcode in a div so that you can target the view inside that div.

For e.g

<div class="my-view">
[wpv-view name='my-view']
</div>

This support ticket is created 2 years, 9 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Saul Baizman 2 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#2453167

Hi there,

I'm using the legacy Types / Views / Layouts plugins. I'm trying to create a CSS rule that targets a particular element that has been generated from a View. It appears to be the case that Views outputs HTML like this...

<div id="wpv-view-layout-908-TCPID6113" class="js-wpv-view-layout js-wpv-layout-responsive js-wpv-view-layout-908-TCPID6113" data-viewnumber="908-TCPID6113" data-pagination=...>

There's clearly a usable div ID there. But the problem I've noticed is that the div ID is not consistent between servers (it's different on my development and production servers).

One solution I thought of was to pass a class name to the View. Is that possible to do? (I didn't see a class attribute available in the documentation for the [wpv-view] shortcode at https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view.)

If this isn't possible, is there another way to solve this problem?

Thank you!

Saul

#2453845

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Saul,

Thank you for getting in touch.

I must apologize for the delay in response, however no you won't be able to pass a class attribute to our Toolset view.

My recommendation here is that you wrap the view shortcode in a div so that you can target the view inside that div.

For e.g
<codE>
<div class="my-view">
[wpv-view name='my-view']
</div>

[/php]

Please let me know if this helps.
Thanks,
Shane

#2453883

Thanks, Shane! I appreciate it!