I am new with WordPress so apologize if i am doing this in a wrong way. I have lot of taxonomies and posts types. I am using one term (from any of the taxonomy) in more then one places in my menu but i want to implement post loop depending on menu id and all its parent id. I am getting menu id with this code.
add_filter( 'wp_nav_menu_objects', 'wpse16243_wp_nav_menu_objects' );
function wpse16243_wp_nav_menu_objects( $sorted_menu_items ){
foreach ( $sorted_menu_items as $menu_item ) {
if ( $menu_item->current-menu-item ) {
$GLOBALS['wpse16243_title'] = $menu_item->ID;
break;
}
}
return $sorted_menu_items;
}
Then i am getting menu title and its parent menu title and then implement WordPress tax_query to implement loop to display posts accordingly.
Every thing works perfectly but i have only issue when i am using term in more then one places because it always return id of first occurrence of this term in my menu. The reason behind this is that "current-menu-item" class is assigned to all occurrence of this term in my menu. When this happen my loop could not show correct posts. According to my view this class should assigned to only my currently active menu item instead of all occurrence of this term. I ll need your suggestion to fix this issue. Your help will be much appreciated. Thank you!