Home › Forums › Welcome! › Pre-Sales Questions › Add categories as css classes
- This topic has 2 replies, 2 voices, and was last updated 10 years, 3 months ago by
Support Droid.
-
AuthorPosts
-
November 6, 2015 at 2:42 am #1022472
Xavi
GuestHello,
In the single-event.php I need to add the category class to the div containing the schedule details and the cost.
I’ve tried tribe_get_event_taxonomy() and tribe_meta_event_cats(), but it adds some weird HTML tags. Also the following function: get_the_terms(), but there is a warning instead of the css classes.
Here is an example of the code with “get_the_therms()”
<div class=”tribe-events-schedule updated published tribe-clearfix <?php get_the_terms() ?>” >
Here is the warning:
tribe-events-schedule updated published tribe-clearfix <br /> <b>Warning</b>: Missing argument 1 for get_the_terms(), called in /Applications/XAMPP/xamppfiles/htdocs/w/wp-content/plugins/the-events-calendar/src/views/single-event.php on line 35 and defined in <b>/Applications/XAMPP/xamppfiles/htdocs/w/wp-includes/category-template.php</b> on line <b>1352</b><br /> <br /> <b>Warning</b>: Missing argument 2 for get_the_terms(), called in /Applications/XAMPP/xamppfiles/htdocs/w/wp-content/plugins/the-events-calendar/src/views/single-event.php on line 35 and defined in <b>/Applications/XAMPP/xamppfiles/htdocs/w/wp-includes/category-template.php</b> on line <b>1352</b><br />Any help would be much appreciated.
November 6, 2015 at 8:56 am #1022580George
ParticipantHey @Xavi!
No customization is needed to get the Category names added as classes to an event – the plugin already does this, and I would recommend removing all custom code related to this.
The classes are on the parent div of the event container. So, for example, if you have an event that belongs to the event categories “Barbecue”, “Concert”, “Convention”, and “Meeting”, then all of the following class names are added to the event container in all plugin views:
• tribe_events_cat-barbecue
• tribe_events_cat-concert
• tribe_events_cat-convention
• tribe_events_cat-meetingAnd so if you wanted to target the Schedule Details for events in the Barbecue category, you’d use CSS like this:
.tribe_events_cat-barbecue .tribe-events-meta-group {
color: red !important;
}
And as you can see it changes the details to the color red, which is gross but just an illustrative example 🙂

I hope that helps!
George
February 18, 2016 at 8:30 am #1075456Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Add categories as css classes’ is closed to new replies.
