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

PHP: Date Difference for PHP 5.2

HTML5 video loop src change on end play function

display the_content with setup_postdata