Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've got a default main menu:

wp_nav_menu(); 

But it gives a list of links in a form:

(...)
<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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
this is the way to go! I was thinking more about add_filter('nav_menu_css_class' (...) answer, but it also work. Menu requires JS anyways, so I'll do that this way. By they way, I totally don't want to delete titles I just don't want a items to display yellow popups above them on hover. But I believe it's not possible without getting rid of titles, right? –  Wordpressor Apr 3 '11 at 9:42
    
This is something the browser does. For example, IE will display the yellow popups when there is an ALT set on an image, even if there is no title set. Other browsers usually only show the popup if the title is set. You might consider a greasemonkey script (ff) or userscript (chrome) that would remove title attributes on whatever page you're viewing. That way you're not annoyed while the people who visit your site can still benefit from the title attributes that they are used to on most websites. –  cwd Apr 3 '11 at 14:25
add comment

Hi @Wordpressor:

I'm pretty sure if you clear the "Title Attribute" field in the Appearance > Menu editor that the titles will be removed from the links:

WordPress Menu Admin showing the Link Title Attribute field

share|improve this answer
    
that's a nice one, but won't work for me - I have no menus in "Menus" section, the one I use is automatically generated by Wordpress. –  Wordpressor Apr 3 '11 at 9:31
    
@WordPressor - Your question specifically referred to wp_nav_menu();. Are you trying to remove titles from the results of the fallback function? (pretty sure there's a filter for the page menu fallback function).. –  t31os Apr 3 '11 at 15:47
    
@WordPressor - If you are using the default generated menus then you could solve it by creating an explicit menu, which you will probably need to do unless your site stays extremely simple. –  MikeSchinkel Apr 3 '11 at 21:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.