Home › Forums › Calendar Products › Events Calendar PRO › Add venue css class
- This topic has 6 replies, 2 voices, and was last updated 8 years ago by
Benedikt.
-
AuthorPosts
-
April 6, 2018 at 2:26 am #1498338
Benedikt
ParticipantHey Guys!
I have to change event-details-backgrounds and event-category-backgrounds depending on event-location.– What i did so far:
I added a category for each venue (its only 4 rooms) and added different classes to my body-class -> class = category-nicename.
That works only on category overview, but not on event-detail-pages.What I want to do:
Add the “venue-nicename” to the body class of the current page. Combined with matching css classnames, I could change body-styles for different venues.Could you help me to pimp my body-class-function?
// add category nicenames in body class function category_id_class($classes) { global $post; foreach((get_the_category($post->ID)) as $category) $classes[] = $category->category_nicename; return $classes; } add_filter('body_class', 'category_id_class');April 6, 2018 at 2:39 pm #1499231juanfra
KeymasterHallo Benedikt,
Thank you for reaching out!
Please check that you are using the get_the_category() function when you really want to check the taxonomy. That function only returns the posts categories.
For custom taxonomies, like the ones we use in our plugin, you should take a look at the get_the_terms() function, you can find the function reference page here: https://developer.wordpress.org/reference/functions/get_the_terms/
Best,
Juan.
April 7, 2018 at 2:10 pm #1499749Benedikt
ParticipantHello there!
I dont know how to use the term request output, but the following worked for me:add_filter('body_class','conf_class'); function conf_class($classes) { $post_id = get_the_ID(); $venue = tribe_get_venue($post_id); $venue = 'myVenue-' . $venue; $classes[] = $venue; return $classes; }Enables me to push the event-venue-name in to the body class. The venue based changes, seem to work on filtered event archive pages as well.
Thats’s all right?April 7, 2018 at 2:12 pm #1499750Benedikt
ParticipantHello there!
I dont know how to use the term request output, but the following worked for me:add_filter('body_class','conf_class'); function conf_class($classes) { $post_id = get_the_ID(); $venue = tribe_get_venue($post_id); $venue = 'myVenue-' . $venue; $classes[] = $venue; return $classes; }>> Thanks to Heinz Duschanek – /support/forums/users/hedu/ <<
Enables me to push the event-venue-name in to the body class. The venue based changes, seem to work on filtered event archive pages as well.
Is that a good solution, or will I be in trouble one day?
April 7, 2018 at 2:13 pm #1499751Benedikt
ParticipantHello there!
I dont know how to use the term request output, but the following worked for me:add_filter('body_class','conf_class'); function conf_class($classes) { $post_id = get_the_ID(); $venue = tribe_get_venue($post_id); $venue = 'myVenue-' . $venue; $classes[] = $venue; return $classes; }>> Thanks to Heinz Duschanek <<
Enables me to push the event-venue-name in to the body class. The venue based changes, seem to work on filtered event archive pages as well.
Is that a good solution, or will I be in trouble one day?
April 8, 2018 at 3:14 pm #1500114juanfra
KeymasterHallo Benedikt,
Thank you for the follow-up. I hope you are doing well.
That’s actually great! If it works for your case, then it is perfect. That code shouldn’t be affected in the future. Regarding the taxonomy, given the first code you have shared I thought you wanted to add the event categories to the body classes and not the venue. The venue is not a taxonomy, so I’d go with the code you shared.
Please let me know if you have any other questions. Have a great day.
Thanks,
Juan.
-
AuthorPosts
- The topic ‘Add venue css class’ is closed to new replies.
