0

I'm trying to output the page title via wp_nav_menu() as a tooltip (.pop_up). The menu text has been replaced by an icon, and using CSS to hide it.

Any ideas how this could be adapted to output the string name where the text "MENU LINK" is shown? Is this actually possible?

wp_nav_menu( array(
    'menu'  => 'Main Menu',
    'after' => '<div class="pop_up">MENU LINK</div>'
));

1 Answer 1

0

Found a way... instead of using wp_nav_menu()

$menu_name = 'main-menu';

if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
    $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );

    $menu_items = wp_get_nav_menu_items($menu->term_id);

    $menu_list = '<ul id="menu-main-menu">';
    foreach ( (array) $menu_items as $key => $menu_item ) {
        $title = $menu_item->title;
        $url = $menu_item->url;
        $id = $menu_item->ID;
        $menu_list .= '<li id="menu-item-' . $id . '"><a href="' . $url . '"></a><div class="pop_up">' . $title . '</div></li>';
    }

    $menu_list .= '</ul>';

}

echo ($menu_list);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.