Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Adding a Bootstrap tooltip to a menu item?

Discussion in 'Misc WordPress Requests' started by anonymousraft, Feb 23, 2018.

  1. anonymousraft

    Guest

    Reply To: Adding a Bootstrap tooltip to a menu item?, by anonymousraft

    Hello @thetoolman123

    To add a custom attribute like to a specific nav menu item’s anchor, Their is a filter available to add this nav_menu_link_attributes

    add_filter( 'nav_menu_link_attributes', 'filter_function_name', 10, 3 );
    function filter_function_name( $atts, $item, $args )
    {
    // Set the menu ID(You can get ID from the chrome inspector for the specific menu item)
    $menu_link = 1215;
    // Conditionally match the ID and add the attribute and value
    if ($item->ID == $menu_link) {
    $atts['data-toggle'] = 'tooltip';
    }
    //Return the new attribute
    return $atts;
    }

    for info https://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_link_attributes

    Thank You

    Reply To: Adding a Bootstrap tooltip to a menu item?
     
    #1

Share This Page

Monarch Social Sharing Plugin