- This topic has 6 replies, 2 voices, and was last updated 10 years, 6 months ago by
Tom.
-
AuthorPosts
-
September 28, 2015 at 2:47 pm #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?
September 29, 2015 at 12:05 am #140543Tom
Lead DeveloperLead DeveloperHi 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 🙂
September 29, 2015 at 2:11 am #140587Andreas
Hi Tom ,
now I have used a custom URL. The “Vehicles” tab is now highlighted but also the “News” tab.
September 29, 2015 at 3:15 am #140593Andreas
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.September 29, 2015 at 4:03 am #140619Andreas
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.
September 29, 2015 at 6:11 am #140661Andreas
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!
September 29, 2015 at 9:26 am #140693Tom
Lead DeveloperLead DeveloperDid 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-ancestorThese 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?
-
AuthorPosts
- You must be logged in to reply to this topic.