Add categories as css classes

Home Forums Welcome! Pre-Sales Questions Add categories as css classes

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1022472
    Xavi
    Guest

    Hello,

    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.

    #1022580
    George
    Participant

    Hey @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-meeting

    And 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

    #1075456
    Support Droid
    Keymaster

    This 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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Add categories as css classes’ is closed to new replies.