Main menu – get rid of titles?

I’ve got a default main menu:

wp_nav_menu(); 

But it gives a list of links in a form:

Read More
(...)
<a href="link" title="PageName">PageName</a>
(...)

The very important question is, how to force WP to display it like:

  (...)
  <a href="link">PageName</a>
  (...)

I don’t like the yellow boxes appearing every time I hover anything in menu.

I know it’s possible, because I’ve seen it working, but no idea how? Filters maybe? Any ideas?

Related posts

Leave a Reply

4 comments

  1. The title is an accessibility attribute that helps users with screen readers. It is part of the recommended WC3 standard for navigation items. Just think about that before you decide to eliminate it because you find it annoying.

    Rather than modifying the PHP code, you could think about removing it after it’s loaded. It’s very easy to do this with jQuery. First, add this to your functions.php file:

    wp_enqueue_script('jquery');
    

    Next, in your site.js file, add this code:

    <script type="text/javascript" >
    jQuery(document).ready(function($){
      $('.nav li a').removeAttr('title');
    }
    </script>
    

    Again, I don’t really recommend doing this, but this is how to accomplish it.

  2. I have had the same problem and I solve this via wp.

    if you ( as like as me before ) cannot see the title attribute in wp menu, check this :

    1. Go to Appearance > Menus.
    2. In the upper right corner ( mine was left corner ! ), click on Screen Options and ensure the “lable” boxes is checked.
    3. now you can edit or remove the label text in menu item.
  3. The accepted solution is a jQuery jerky solution. This is the WordPress PHP solution:

    Add to your functions.php this:

    /* REMOVE TITLES ON MENU */
    function my_menu_notitle( $menu ){
      return $menu = preg_replace('/ title="(.*?)"/', '', $menu );
    
    }
    add_filter( 'wp_nav_menu', 'my_menu_notitle' );