#23130 closed defect (bug) (duplicate)
nav_menu and custom taxonomies
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Menus | Version: | 3.1.4 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I found out that in case when you have some custom taxonomies, their terms could has the same term_id. The case is when two(or more) terms with the same term_id but from different taxonomies are added to Nav Menu, and the user is in one of this terms - they are both marked like active in menu.
This is because of lacking condition in _wp_menu_item_classes_by_context function in wp-includes/nav-menu-template.php file:
// if the menu item corresponds to the currently-queried post or taxonomy object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ))
)
) {
but it needs to be like that:
// if the menu item corresponds to the currently-queried post or taxonomy object
} elseif (
$menu_item->object_id == $queried_object_id &&
(
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax )/*ADDED CODE-->*/ && $menu_item->object==$queried_object->taxonomy/* <--ADDED CODE*/)
)
) {
I found this bug on 3.1.4 version, but looks like it still remains on the las version of wordpress.
Change History (3)
comment:1
SergeyBiryukov — 5 months ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
comment:2
SergeyBiryukov — 5 months ago
Fixed in [22302].
comment:3
SergeyBiryukov — 5 months ago
- Version changed from 3.5 to 3.1.4
Note: See
TracTickets for help on using
tickets.

Duplicate of #21369.