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:(...)<a href="link"

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?

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 asked Apr 3, 2011 at 2:14 WordpressorWordpressor 5,05119 gold badges70 silver badges102 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 4

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.

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:

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.

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' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745076758a4609881.html

相关推荐

  • 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:(...)<a href="link"

    18小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信