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

Fix for duplicate active menu items. #986

Closed
wants to merge 1 commit into from
Closed

Fix for duplicate active menu items. #986

wants to merge 1 commit into from

Conversation

dalabarge
Copy link

There's a duplication of active menu items when using custom post types. Namely that custom posts nested beneath a page cause the blog to become .active while simultaneously setting the parent page .active and the current menu item .active. This patch fixes all that nonsense. If you print_r($classes); print_r($new_classes) on line 60 you'll see that there are always at least 2 active replaces prior to the array_unique($new_classes). The array_search('current-menu-item',... conditional check is to ensure that .active is still set for current menu item regardless of the number of $new_class_counts.

There's a duplication of active menu items when using custom post types. Namely that custom posts nested beneath a page cause the blog to become `.active` while simultaneously setting the parent page `.active` and the current menu item `.active`. This patch fixes all that nonsense. If you `print_r($classes); print_r($new_classes)` on line 60 you'll see that there are always at least 2 active replaces prior to the `array_unique($new_classes)`. The `array_search('current-menu-item',...` conditional check  is to ensure that `.active` is still set for current menu item regardless of the number of `$new_class_counts`.
@retlehs
Copy link
Sponsor Member

retlehs commented Feb 6, 2014

@Foxaii has a nav rejig branch that handles this which will be merged in soon

@dalabarge
Copy link
Author

Dang, wish I knew. His looks a lot fancier and probably more tested. This solved my problem in a down and dirty way. Feel free to close if you don't use it.

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

Successfully merging this pull request may close these issues.

None yet

3 participants