Support » Plugin: The Events Calendar » Classes gone missing on event category page index tag

  • Resolved Rom Soul

    (@rom-soul)


    Hi,

    On event category pages the <body> element has a lot of classes :
    class="archive post-type-archive post-type-archive-tribe_events logged-in admin-bar tribe-js [...]"

    But one class is gone cruelly missing in the latest versions of the plugin, that was proper to the displayed category:
    events-category-xyz
    xyz being the slug of the category.

    How can I include it back among <body> classes ?
    Some of my CSS theme was relying on it and is now unusable .

    • This topic was modified 7 months, 1 week ago by Rom Soul.
    • This topic was modified 7 months, 1 week ago by Rom Soul.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Victor Zarranz

    (@vicskf)

    Hi @rom-soul,

    Thanks for reaching out!

    We are moving away from using body classes and more towards container classes.

    The events-category-xyz class is only present when using the old calendar views. The new updated designs don’t have that class in the body.

    If needed, you can use the following snippet into your function.php file to add the category class into the body for the new updated views:

    add_filter( 'body_class', function( $classes ) {
        $cat = tribe( 'context' )->get( 'tribe_events_cat' );
        if ( empty( $cat ) ) {
            return $classes;
        }
        return array_merge( $classes, [ 'events-category-' . $cat ] );
    } );

    Just in case you need it, here’s a guide on how to implement snippets -> https://theeventscalendar.com/knowledgebase/k/best-practices-for-implementing-custom-code-snippets/

    Hope that helps 🙂

    Thread Starter Rom Soul

    (@rom-soul)

    Thanks a lot Victor,

    This is exactly what I needed !
    My precious class is back :
    <body class=" [...] events-category-my-event-cat">

    I can style my event category page like I want, this is great 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Classes gone missing on event category page index tag’ is closed to new replies.