Home › Forums › Calendar Products › Events Calendar PRO › add venue body class
- This topic has 2 replies, 2 voices, and was last updated 7 years, 12 months ago by
Benedikt.
-
AuthorPosts
-
April 25, 2018 at 9:19 am #1515938
Benedikt
ParticipantHey there!
I want to add the venue nicename to my body class and change the background depending on the venue the event is listed for. The event overview body however needs to be untouched.
My Problem: The venue classes are all added up to the body whenever the overview “events” is opened. So all bodys are being loaded. I found a solution, but im not sure if its really stable – Im not in to php to be honest.‘add_filter(‘body_class’,’conf_class’);
function conf_class($classes) {$post_id = get_the_ID();
$venue = tribe_get_venue($post_id);if (is_tax()){
$venue = ‘myVenue-‘ . $venue;
$classes[] = $venue;
return $classes;
} else {return $classes;}
}’My questions on this peace of code:
– I added “is_tax()” because it ocures to me, that “events” page has no custom taxonomies – can I ask for specific taxonomies like string “category nicename” here? Would be better I guess. something like “if is_tax(“category name”).
– In the end I had to return the untouched classes. If I dont return them, some classes go missing (like for closed tribe filter bar). Is that correct?
April 25, 2018 at 9:46 am #1516041Benedikt
ParticipantUpdate: oaky, my code does not really make sense.
What I need to do:
I need to ask for the venue name before I can add the body class.
-> if is venue x? add body class x
-> if is venue y? add y
-> if is both add nothing
-> is “events” add nothing.How can I do that?
Something like this?
add_filter('body_class','conf_class'); function conf_class($classes) { $post_id = get_the_ID(); $v1 = 'Docks'; $v2 = 'Prinzenbar-Hamburg'; $venue = tribe_get_venue($post_id); if ($venue == $v1 ^ $v2){ $venue = 'myVenue-' . $venue; $classes[] = $venue; return $classes; }else {return $classes;} }-
This reply was modified 8 years ago by
Benedikt.
April 26, 2018 at 9:48 am #1517055Victor
MemberHi Benedikt! This is a duplicate of https://theeventscalendar.com/support/forums/topic/add-venue-based-class-to-body/ so I’ll go ahead and close it.
Please refer to that thread so I can help you further 🙂
Thanks,
Victor -
This reply was modified 8 years ago by
-
AuthorPosts
- The topic ‘add venue body class’ is closed to new replies.
