WordPress filter hook · part of WordPress core

nav_menu_link_attributes

A WordPress core filter that 92 plugins also fire themselves, running on 3.6M+ sites between them.

“Filter the HTML attributes applied to a menu item's anchor element.”

How to use nav_menu_link_attributes

It's a filter: your callback receives the value and 3 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'nav_menu_link_attributes', function( $atts, $item, $args, $depth ) {
	// Change $atts here.
	return $atts;
}, 10, 4 );

Argument names come from ElementsKit Elementor Addons's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

92 plugins that fire nav_menu_link_attributes

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. ElementsKit Elementor Addons icon ElementsKit Elementor Addons1+ million installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) modules/megamenu/walker-nav-menu.php:292
  2. Premium Addons for Elementor icon Premium Addons for Elementor600,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/helpers/pa-nav-menu-walker.php:371
  3. Royal Addons for Elementor icon Royal Addons for Elementor600,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) modules/mega-menu/walkers/class-wpr-main-menu-walker.php:162
  4. HappyAddons for Elementor icon HappyAddons for Elementor400,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) extensions/walker-nav-menu.php:151
  5. Page Builder: Pagelayer icon Page Builder: Pagelayer400,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) main/nav_walker.php:182
  6. The Plus Addons for Elementor icon The Plus Addons for Elementor100,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) modules/helper-function.php:262
  7. Jupiter X Core icon Jupiter X Core70,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/extensions/raven/includes/modules/nav-menu/classes/walker-nav-menu.php:311
  8. Responsive Menu icon Responsive Menu70,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) v4.0.0/inc/classes/class-walker.php:179
  9. AMP for WP icon AMP for WP70,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) classes/class-ampforwp-walker-nav-menu.php:62
  10. Gum Addon for Elementor icon Gum Addon for Elementor50,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) helper.php:333
  11. Xpro Addons icon Xpro Addons40,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) classes/class-xpro-navwalker.php:207
  12. Master Addons for Elementor icon Master Addons for Elementor30,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/modules/display/mega-menu/inc/walker-nav-menu.php:236
  13. Header Footer Builder for Elementor icon Header Footer Builder for Elementor30,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/class-tahefobu-megamenu.php:910
  14. Apollo13 Framework Extensions icon Apollo13 Framework Extensions20,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) widgets/widget-menu-walker.php:97
  15. Thim Elementor Kit icon Thim Elementor Kit20,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/modules/mega-menu/class-menu-walker.php:146
  16. Animation Addons for Elementor icon Animation Addons for Elementor10,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) widgets/nav-menu/walker-nav-menu.php:218
  17. LA-Studio Element Kit for Elementor icon LA-Studio Element Kit for Elementor10,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-nav-walker.php:206
  18. Responsive Starter Templates icon Responsive Starter Templates10,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/compatibility/megamenu/class-responsive-legacy-megamenu-nav-walker.php:493
  19. ShiftNav icon ShiftNav10,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/ShiftNavWalker.class.php:287
  20. Bellows Accordion Menu icon Bellows Accordion Menu10,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/BellowsWalker.class.php:377
  21. WP Customer Area icon WP Customer Area10,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) src/php/helpers/bootstrap-nav-walker.class.php:90
  22. Landing Page Builder icon Landing Page Builder8,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) public/templates/widgets/navBuilderMenuWalker.php:121
  23. Themify Builder icon Themify Builder6,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) themify/megamenu/class-mega-menu.php:134
  24. Ultimate Bootstrap Elements for Elementor icon Ultimate Bootstrap Elements for Elementor6,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/walker/bootstrap-nav.class.php:194
  25. Spexo Addons for Elementor icon Spexo Addons for Elementor6,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/modules/mega-menu/walkers/class-tmpcoder-main-menu-walker.php:156
  26. EasyMega icon EasyMega5,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/menu.php:299
  27. Floating Button icon Floating Button4,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) classes/Publish/Navigation.php:109
  28. Groovy Menu Plugin (Free) icon Groovy Menu Plugin (Free)4,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/modules/walkers/inc/FrontendSimpleWalker.php:130
  29. News Kit Addons For Elementor icon News Kit Addons For Elementor3,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/vendors/custom-walker.php:190
  30. RS Template Builder For Elementor icon RS Template Builder For Elementor2,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/helpers/class-nav-walker.php:91
  31. Gecka Submenu icon Gecka Submenu2,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) gecka-submenu.class.php:272
  32. Menu In Post icon Menu In Post2,000+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) class-mipwalkernavmenulistbuilder.php:98
  33. Custom CSS icon Custom CSS900+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) fresh-framework/framework/themes/functions/class.ffNavMenuWalker.php:173
  34. MAS Elementor icon MAS Elementor800+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) classes/class-wp-bootstrap-navwalker.php:271
  35. Anant Addons for Elementor icon Anant Addons for Elementor700+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) inc/anant-custom-navwalker.php:84
  36. Star Addons for Elementor icon Star Addons for Elementor700+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-star-addons-navwalker.php:190
  37. AMP WP icon AMP WP600+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-amp-wp-menu-walker.php:252
  38. ST Elementor Addons icon ST Elementor Addons500+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/nav-menu/stea-nav-menu-helper.php:37
  39. Topper Pack icon Topper Pack400+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/mega-menu/init.php:544
  40. Blog News Addons For Elementor (News, Magazine and Blog Addons) icon Blog News Addons For Elementor (News, Magazine and Blog Addons)400+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) inc/custom-navwalker.php:93
  41. Opal Mega Menu icon Opal Mega Menu300+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-menu-walker.php:119
  42. CRT Addons Builder and Widgets for Elementor icon CRT Addons Builder and Widgets for Elementor300+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/customizer/addons/class/mega-menu/walkers/class-crt-main-menu-walker.php:163
  43. Visual Builder icon Visual Builder200+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) menu/menu-menu.php:251
  44. STAX Header Builder icon STAX Header Builder200+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) core/helpers/MenuWalker.php:66
  45. Elementor Post Grid icon Elementor Post Grid200+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) includes/custom-navwalker.php:93
  46. Shopready icon Shopready100+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) src/base/Nav_Walker.php:159
  47. Funtionalities for Alpus theme icon Funtionalities for Alpus theme100+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) framework/addons/walker/class-alpus-walker-nav-menu.php:286
  48. TP Flatsome Vertical Menu icon TP Flatsome Vertical Menu100+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/class-tp-vertical-menu-dropdown.php:210
  49. Responsive Mobile Select Menu icon Responsive Mobile Select Menu100+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-menu-walker.php:121
  50. Awesome Widgets for Elementor icon Awesome Widgets for Elementor100+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) widgets/awesome-nav-menu/awesome-nav-menu.php:67
  51. Vertical Menu Block for Sidebar Accordion Menu icon Vertical Menu Block for Sidebar Accordion Menu90+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/Utils/WalkerMenu.php:29
  52. GW Elementor Addons icon GW Elementor Addons80+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/ext-navigation-walker.php:49
  53. WiraKit For Elementor icon WiraKit For Elementor70+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/widgets/nav-menu/class-bootstrap-navwalker.php:90
  54. MerKit Theme Builder and Template Library for Elementor icon MerKit Theme Builder and Template Library for Elementor60+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/widgets/class-merkit-nav-menu-widget.php:1174
  55. Atomic Addons icon Atomic Addons50+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/mega-menu/classes/class-mega-menu-walker.php:205
  56. Kemet Addons icon Kemet Addons30+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) addons/mega-menu/classes/class-kemet-addon-mega-menu-walker-nav-menu.php:223
  57. Xolo Addon icon Xolo Addon30+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/erapress/class-wp-bootstrap-navwalker.php:210
  58. Zyre Elementor Addons icon Zyre Elementor Addons20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) classes/walker-nav-menu.php:183
  59. Page Load Ajax icon Page Load Ajax20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) page-load-ajax.php:625
  60. Elite Elementor Addons and Widgets icon Elite Elementor Addons and Widgets20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) modules/mega-menu/walkers/class-elite-main-menu-walker.php:162
  61. Custom Sidebars Manager icon Custom Sidebars Manager20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) fresh-framework/framework/themes/functions/class.ffNavMenuWalker.php:173
  62. Easy icon Easy20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) 2046-easy.php:1190
  63. Architect icon Architect20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) widgets/class-archt-menu-walker.php:121
  64. Posts Per Page Customizer icon Posts Per Page Customizer20+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) fresh-framework/framework/themes/functions/class.ffNavMenuWalker.php:173
  65. SiteCraft icon SiteCraft10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/Elementor/Widgets/Nav_Menu/Sc_Menu_Walker.php:222
  66. Octagon Elements for Elementor icon Octagon Elements for Elementor10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) core/megamenu/class-walker-nav-menu.php:229
  67. QuickStart icon QuickStart10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/helpers/walkers/class-walker-inline-nav-menu.php:120
  68. UNIVERSAM icon UNIVERSAM10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/taxonomy/class-walker-product_category-columns-menu.php:84
  69. TRIPLE PRICING TABLE icon TRIPLE PRICING TABLE10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) assets/wp_bootstrap_navwalker.php:93
  70. Ultimate AMP icon Ultimate AMP10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) inc/menu-walker.php:88
  71. UXD Widgets for Elementor icon UXD Widgets for Elementor10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) widgets/sticky-menu-widget.php:1284
  72. Pimap icon Pimap10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) Odin/core/classes/class-bootstrap-nav.php:93
  73. Real Estate Listings Plugin for Professionals icon Real Estate Listings Plugin for Professionals10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) includes/Mwp/Theme/Layout/NavWalker.php:77
  74. Awesome Studio icon Awesome Studio10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) monoframe/menu-walkers/wp_bootstrap_navwalker.php:96
  75. Endless Addons icon Endless Addons10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-endless-addons-navwalker.php:190
  76. Terme Nav Menu Icon icon Terme Nav Menu Icon10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) inc/nav-menu-walker.php:45
  77. RSG Compiled Libraries icon RSG Compiled Libraries10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) my-lib/rsg/functions/wp_bootstrap_navwalker.php:93
  78. Flyout Menu Awesome by Themes Awesome icon Flyout Menu Awesome by Themes Awesome10+ installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) nav-menu-walker.php:34
  79. Glossy Mega Menu icon Glossy Mega MenuFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/classes/class-glossymm-menu-walker.php:205
  80. DesignSuite icon DesignSuiteFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/Elementor/Widgets/Nav_Menu/Ds_Menu_Walker.php:222
  81. Fine MCP icon Fine MCPFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/offcanvas-walker-nav.php:167
  82. Arshida Toolkit for WooCommerce icon Arshida Toolkit for WooCommerceFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) src/Menu/MenuWalker.php:224
  83. Wbee Header Footer and Mega Menu Builder for Elementor icon Wbee Header Footer and Mega Menu Builder for ElementorFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/ThemeBuilder/Nav/Walker.php:104
  84. QuickDocs icon QuickDocsFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, array(), 0 ) src/template-tags.php:282
  85. Rooster LMS icon Rooster LMSFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/Elementor/MenuWalker.php:64
  86. Fly Nav Mobile icon Fly Nav MobileFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) backend/class-fly-nav-mobile-walker.php:71
  87. Apex Addons for Elementor icon Apex Addons for ElementorFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) widgets/nav-menu-widget.php:1071
  88. Vantorix icon VantorixFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) inc/helpers/class-nav-walker.php:101
  89. Responsive Bold Navigation icon Responsive Bold NavigationFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args ) walker.php:43
  90. Online Help Sliding Menu icon Online Help Sliding MenuFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) OHSM_Walker_Nav_menu.php:71
  91. Carbon Based Mobile Menu icon Carbon Based Mobile MenuFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ) includes/class-cbsmm-walker.php:56
  92. Header Footer & Mega Menu Builder for Elementor icon Header Footer & Mega Menu Builder for ElementorFewer than 10 installs apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth ) includes/class-hfammbfe-megamenu.php:398

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.