Remove Title Attribute from WordPress Menu Link

By default, WordPress menu functions, like wp_page_menu(), wp_nav_menu() or wp_list_categories() display menu links with title attribute.

Here’s the code to remove it from wp_page_menu(), wp_nav_menu() and wp_list_categories() function: 


function menu_notitle( $menu ){
  return $menu = preg_replace('/ title=\"(.*?)\"/', '', $menu );

}
add_filter( 'wp_nav_menu', 'menu_notitle' );
add_filter( 'wp_page_menu', 'menu_notitle' );
add_filter( 'wp_list_categories', 'menu_notitle' );


Put the code in your theme funtion.php and no more title attribute in the menu.

Comments

Popular posts from this blog

HTML5 video loop src change on end play function

Set limit wp_nav_menu

Calculate percentage of a specific element has been scrolled into visible on the screen