Support » Theme: raindrops » Menu Title Attribute

  • Resolved snowme

    (@snowme)


    Hi,

    I’m trying to add the title attribute to a menu item but it doesn’t appear. Is there a script removing the title attribute from links?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author nobita

    (@nobita)

    Hi @snowme

    The WordPress Core does not display the title attribute of the link element with tooltips.

    please try code below.

    add functions.php

    
    <?php
    add_filter( 'nav_menu_link_attributes', 'my_nav_menu_attr_add', 10, 3 );
    
    function my_nav_menu_attr_add( $atts, $item, $args ) {
        
        if ( ! empty( $item->attr_title ) ) {
    		/**
    		 * Add title attribute for a element
    		 */
            $atts['attr_title'] = esc_attr( $item->attr_title );
    		/**
    		 * Raindrops 
    		 * To display the value of the title attribute with the tooltip with the a element, 
    		 * the raindrops theme needs the tooltip class.
    		 */
    	$atts['class'] = 'tooltip';
    		
    		return $atts;
        }
        return $atts;
    }
    ?>
    

    and require change Theme setting

    Customize / Presentation / Menu /

    Sticky Menu set No.

    Save and Publish

    Thank you.

    Thank you Nobita.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Menu Title Attribute’ is closed to new replies.