1

I have a menu item Services which has 5 submenus. Now when I click on one of those submenus, like Flexible Endoscopes I manage to echo the title of child item or current page title. But I can't find any info on how to output parent menu item name. I found a method called menu_item_parent but that just prints number to the screen and not the title. How can I echo both Services menu name and its current displayed submenu item Flexible Endoscopes? My current code that just prints a number to the screen:

add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt');

    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 ) {
        var_dump($GLOBALS['wpse16243_title'] = $menu_item->menu_item_parent);
        break;
    }
    }
    return $sorted_menu_items;
    }

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.