Skip Navigation

[Résolu] Add CSS class to View block

This support ticket is created Il y a 4 années et 6 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 3 réponses, a 2 voix.

Dernière mise à jour par nicholasM Il y a 4 années et 5 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1650871

There doesn't seem to be a way to add a custom CSS class to the View block.

#1650897

As discussed in our chat, the current workaround is to add a Container block and insert your View block inside the Container. Container blocks allow you to add custom CSS classes and ID. I have asked my 2nd tier support team to consider this as a missing feature or to let me know if there is something obvious I have missed. I will let you know what I find out.

#1653279
Screen Shot 2020-06-07 at 10.02.50 AM.png

Okay I got some feedback from 2nd tier, and it seems there is no other simple way to achieve this - wrapping the View block in a Container block is the best way to add custom CSS class or ID as an ancestor of the View's loop elements. We have put in a request to add "Advanced" settings to the View block and the View Output block unless there is a good reason not to do so. The View Search block already has these settings.

If you need the ability to add a CSS class to an element before the View's loop, but not necessarily to add the class to an ancestor of the loop elements, please note the attached screenshot. You can insert content after the View loop, then hover over that block and use the up and down arrows ("Move up" in the screenshot) to reorder the block elements such that the hookable element is before the View's loop but still inside the View Output block.

Thanks for the report, and be assured our developers will add the Advanced panel in upcoming releases of Views and Blocks.

#1653427

Sounds good, thanks!