• There’s a dropdown menu on the site. Some item lead directly to pages and some to category archives. When user click the item that leads to page (either the parent item or the child – dropdown) WordPress sets proper classes like: current-page-item, current-page-ancestor… Anyway, everything works fine.

    However, when user click on any item that leads to the category archive no “active” classes are set at all, so I cannot properly style the active item.

    After some research I’ve found this:

    function add_custom_classes($classes, $item){
        if (is_category()) {
           	 $classes[] = 'current-menu-item';
        }
        return $classes;
    }
    
    add_filter('nav_menu_css_class' , 'add_custom_classes' , 10 , 2);

    Yet, it still doesn’t add any classes, no matter if you click the child or the parent menu item.

    There’s some kind of custom URL structure whithout the “category” word in it (so it’s directly like foo.bar\category-name\) and I’m not allowed to change it.

    Any ideas?

Viewing 1 replies (of 1 total)
  • Thread Starter Adam Czajczyk

    (@ambiantepl)

    I know it’s not nice to “up” my own post, but 4 days and I still didn’t find any solution. Does anyone have any ideas maybe…?

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘No current-menu-item for categories’ is closed to new replies.