[Resolved] Highlight in menu nav

Home Forums Support [Resolved] Highlight in menu nav

Home Forums Support Highlight in menu nav

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #140491
    Andreas

    Hi Tom,

    I’ve copied and changed the single.php to issue Custom Post Types.

    Unfortunately, the Blog in my case “news” tab gets highlighted in nav menu. I want to change it so that the “Fahrzeuge” tab is highlighted correctly.

    Have you any idea how I can implement it?

    #140543
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Something WordPress can become confused between custom post types and the regular post type.

    I did some searching on this and didn’t find any specific fixes.

    Can you try adding the URL to your Blog as a “Custom Link” in “Appearance > Menus”.

    Let me know if that helps or not 🙂

    #140587
    Andreas

    Hi Tom ,

    now I have used a custom URL. The “Vehicles” tab is now highlighted but also the “News” tab.

    #140593
    Andreas

    Probably “News” is highlighted as it is in both sides is an archive.
    Here is now to understand how the active classes will be awarded for the menu nav and accordingly may intervene from the archives vehicles or single vehicles.

    #140619
    Andreas

    It is devinitiv a problem with the Theme. If I used a standard WPTheme the “blog” tab is not highlighted.

    That means we have to change anything so that the Custom Posts get display highlighted in the right way.

    #140661
    Andreas

    Hi Tom,

    with this little Code I can highlight the “Fahrzeuge” tab in navigation

    function custom_active_item_classes($classes = array(), $menu_item = false) {
            global $post;
            $classes[] = ($menu_item->url == get_post_type_archive_link($post->post_type)) ? 'current-menu-item active' : '';
            return $classes;
    }
    add_filter( 'nav_menu_css_class', 'custom_active_item_classes', 10, 2 );

    But the “News” tab I still active!

    #140693
    Tom
    Lead Developer
    Lead Developer

    Did you try adding the “News” menu item as a “Custom Link” and not a “Page”?

    GP makes use of three WordPress classes:

    .current-menu-item
    .current-menu-parent
    .current-menu-ancestor

    These are built into WP, but I have a feeling that one of them is rarely used anymore and is the cause of this issue.

    Can you link me to one of your single custom post types templates so I can see which class is causing the News item to be highlighted?

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.