WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#23130 closed defect (bug) (duplicate)

nav_menu and custom taxonomies

Reported by: dmikam Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1.4
Component: Menus Keywords:
Focuses: 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)

#1 @SergeyBiryukov
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #21369.

#3 @SergeyBiryukov
8 years ago

  • Version changed from 3.5 to 3.1.4
Note: See TracTickets for help on using tickets.