Skip Navigation

[Resolved] Use taxonomy as css class in View Loop

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

Problem:
How to use the taxonomy as the HTML class attribute for CSS styling?
Solution:
- Enable the legacy views:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/
- Use the steps below to create the view:
https://toolset.com/documentation/legacy-features/views-plugin/
- Now you will have access to the HTML code and you can use the views shortcodes to add the taxonomy as an HTML class.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/

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.

This topic contains 4 replies, has 2 voices.

Last updated by rubenM-3 2 years ago.

Assisted by: Christopher Amirian.

Author
Posts
#2489483

Hi,
I'd like to use a custom taxonomy, created in Toolset, in a View Loop, so I can style each Custom Post using this taxonomy. Now it shows only general classes "wp-block-toolset-views-view-template-block wpv-block-loop-item php-to-be-replaced-with-shortcode".

Thank you!

#2490587

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

It is not possible with the Views block. You can enable the Legacy Views mode where you can use HTML code to add the loop content and there you can use the proper shortcode to add the class for your CSS styling.

To enable the legacy mode:

https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

Here is how to create a view loop:

https://toolset.com/documentation/legacy-features/views-plugin/front-page-filters/

You can use the Fields and Views button in the editor to add whatever custom field or taxonomy that you want. It will be added into the code as a shortcode and you can use that shortcode to add in the CLASS attribute of your HTML container.

Thanks.

#2490735

Hi Christopher,
thank you. I've created a View in legacy mode, and I can use taxonomy in class. Great. But formatting in legacy mode is a bit difficult. For example, can I create columns in Legacy Mode? And also I'd like to use Toolset Grid, but I don't know how to do it. And as I use Divi as theme, I can't use Bootstrap grid.

Thank you!

#2491031

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

The legacy views use Bootstrap for the formatting and grid and column. It gives a basic wizard that you can use, but for sure you will need to be familiar with Bootstrap for doing additional customization.

I suggest that you read the documentation below that will give you a starting point on how to create grids with legacy Views:

https://toolset.com/documentation/legacy-features/views-plugin/view-layouts-101/

Thank you.

#2493449

My issue is resolved now. Thank you!