highlight current categories in sidebar

Home Forums Calendar Products Events Calendar PRO highlight current categories in sidebar

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1006872
    thomas
    Participant

    hi i use this code to show the categories of the events in the calendar sidebar:

    <ul>
    <?php  $terms = get_terms( TribeEvents::TAXONOMY, array( 'orderby' => 'menu_order' ) );
    foreach ( $terms as $term ) {
    echo '<li><a href="'. get_term_link($term->slug, 'tribe_events_cat') .'" >' . $term->name . '</a></li>'; }?>
    </ul>

    http://www.villa-ver.de/kalender/
    how can i highlight the current event category?
    thanks and keep up the good work!
    thomas

    #1007259
    Geoff
    Member

    Hey Thomas,

    Thanks for the kind words, my friend!

    Good question. The answer will largely depend on how you’ve set up theĀ get_terms() query, but here’s a nice example of how someone was able to accomplish that, shared on StackOverflow.

    Will this help get you started? Please let me know! We’re fairly limited in how much we can support custom development questions, but I’d be happy to help as best I can!

    Geoff

    #1008154
    thomas
    Participant

    he geoff,

    i checked some links and now i have this:

    if( here has to be the right code snippet ) {$termclass = "current-cat";}
    echo '<li class="'. $termclass .'"><a href="'. get_term_link($term->slug, 'tribe_events_cat') .'" >' . $term->name . '</a></li>';

    i just need to check if the current category is viewed to put a “current-cat” class to the li.
    but i don’t know how? anyway the class works …
    thomas

    • This reply was modified 8 years, 7 months ago by thomas.
    • This reply was modified 8 years, 7 months ago by thomas.
    #1008270
    Geoff
    Member

    Hi Thomas,

    I’m afraid this sort of customization is outside the scope of what we can support here on the forums. That said, I’ll certainly try to point you in the right direction, if I can!

    Perhaps something like this can help:

    if ( $post->ID == $page->ID ) { $termclass = "current-cat";} echo '<li class="'. $termclass .'"><a href="'. get_term_link($term->slug, 'tribe_events_cat') .'" >' . $term->name . '</a></li>';

    I hope that helps. If not, I’m be happy to leave this thread open a little longer to see if anyone from the community might be able to chime in with additional ideas.

    Thanks!
    Geoff

    #1013067
    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 5 posts - 1 through 5 (of 5 total)
  • The topic ‘highlight current categories in sidebar’ is closed to new replies.