Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_page_parent css class on menus with CPT #78

Open
nye opened this issue Apr 4, 2024 · 2 comments
Open

current_page_parent css class on menus with CPT #78

nye opened this issue Apr 4, 2024 · 2 comments

Comments

@nye
Copy link

nye commented Apr 4, 2024

I'm using Navi to build my main menu. In this menu there is the regular Blog menu and also a menu corresponding to a CPT.
The problem is when I'm on CPT single page, the Blog menu gets the current_page_parent class.

So I googled and find that I can use this nav_menu_css_class filter to remove the class current_page_parent from the blog menu when I'm in a CPT.

This works fine when I render the menu with wp_nav_menu, but if I use Navi, the blog menu keeps getting the current_page_parent class.

Is there a way to handle this in Navi? Is Navi ignoring the nav_menu_css_class filter or I need to do it some other way?
Maybe I'm missing something...

Thanks!

@Log1x
Copy link
Owner

Log1x commented Apr 4, 2024

Is Navi actually having this class get passed to $item->classes or is $item->active just mistakenly true?

If it's the first, I might have to change how the attribute map works slightly to allow for an array of classes to check for since that class shouldn't ever really come through to begin with.

If it's the latter, I'll have to look into this behavior but for now probably just do an check alongside $item->active similar to whatever conditional you were using in the filter.

@nye
Copy link
Author

nye commented Apr 4, 2024

It's the first case, $item->classes has the current_page_parent class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants