This is how I added data attribute to my menu
It simply adds data-title=”menu-title” to each link on my main nav, change it to adapt to your need.
You don’t actually need to use Nav Walker to add this
add_filter( 'nav_menu_link_attributes', 'cfw_add_data_atts_to_nav', 10, 4 );
function cfw_add_data_atts_to_nav( $atts, $item, $args ) {
$atts['data-title'] = $item->post_title;
return $atts;
}
Related Posts:
- how to change WordPress menu markup/classes
- Custom Navigation build using wp_nav_menu and walker
- WordPress menu walker – Get parent item text inside end_lvl function
- Menu items description? Custom Walker for wp_nav_menu()
- wp_nav_menu(), how to change class?
- Add custom classes to anchor in wp_nav_menu
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- Strict Standards Error bootstrap navwalker
- Any walker causes blank menu?
- How to add menu support to a theme?
- Displaying wp menus by name without using theme locations
- Setting a Default ‘Theme Location’ When Creating a Menu
- Best practices: Custom theme sidebar menu – hardcode or widget?
- Custom Nav Walker to show siblings and children of current branch?
- Create self-populating menu and add extra divs to the menu layout
- which is the best way to customize nav-menu-template.php?
- Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]
- My Admin bar covers my sticky navbar [closed]
- WordPress is adding margins and padding to my custom menu?
- Programmatically (PHP) get the nr. of items in the primary navigation menu
- WordPress empty Nav Menu error
- How to make theme elements customizable in wordpress?
- Primary navigation menu & footer not showing in category / tag page
- Using a page as home, how do I prevent nav from setting both home and page links active?
- Issue on Adding A Class to Bootstrap Navbar Walker Dropdown
- Help with walker for nav
- Child Theme header1.php file not overwriting parent theme’s header1.php file
- how do i develop a global nav and local nav to be wordpress dynamic?
- Remove/Hide a Widget on a Custom Template
- Custom nav menu not showing
- WordPress custom menu can’t show 3. level submenu
- Programatically Created Menu not Editable in Dashboard
- 3 Level Menu Navigation (3rd Level not displaying)
- How can I show a custom WordPress menu anywhere I want on my website?
- Show all menu levels except top level. How to exclude top level of a menu?
- WordPress Menu item > Sub menu Class update
- Need help with adding custom wordpress menu and sub-menu
- How to achieve this navigation style in wordpress navigation
- HTML TO WP Theme : Submenu goes down wp_nav_menu
- Fallback dosen’t work when not using ‘menu’ attribute
- How to add drop symbol to parent nav items which have child
- WordPress 3.9 two menus in same position?
- Horizontal Navigation
- Strict Standards Error bootstrap navwalker
- How to make navigation a list without a plugin? [duplicate]
- wp_nav_menu_items callback not triggered
- wp_nav_menu sort order?
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Adding Post Counts to Menu (Nav) Programmatically?
- Bar separated navigation by extending Walker_Nav_Menu
- How to add nofollow to wp_nav_menu
- Can this navigation be done easily in WordPress?
- Custom Nav Walker Displaying Values in Sub Menu
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- how to wrap tag in tag html to wordpress menu conversion
- How to add categories to wp_list_pages()
- Multiple menu items highlighted
- .sub-menu or .children?
- Set default screen option for appearance -> menus
- How to add a second stylesheet to the editor
- Arguments ignored/markup changed in wp_nav_menu if no menu is selected
- Conditional statement to show pagination
- How do I separate link levels in a custom menu walker?
- How to create a custom template to admin dashboard
- Getting custom posts by post id from cutomizer text input
- Disabling Customizer Selective Refresh shortcut icons for selected controls
- How to wrap the list with custom class using wp_nav_menu?
- Zoom on custom theme without child
- Changing a slider to a grid [closed]
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Get the amount of posts on a given page
- How Do I Add Images To Main Navigation Menu
- Walker menu not displaying at all
- How should I use starter content utility to show some default menus?
- How to transfer one domain to another domain without losing theme options (customizer)?
- Add login hyperlink to secondary navigation menu
- How to make theme configurable
- Thesis -style Navigation
- Create theme for mobile phones and tablets only?
- Using the media library for theme customization
- Alternatives to handle customizer settings
- Seeting Active Nav for Bootstrap in WordPress
- Customize Widget Navigation
- Help with WordPress Custom Nav Walker
- Building a custom menu or use a plugin?
- What is difference between add_theme_support and Theme Customization API?
- Where to place a svg chevron down in my custom walker?
- Is hand coding required at all?
- Output existing wp_nav_menu with a custom walker
- how to split vertical menu into two columns using walker nav menu
- WordPress Customizer Help with FontAwesome Icon
- Can’t add optional class to menu item when using Walker_Nav_Menu
- Menu item not created on theme activation
- Determine if a navigation item has children
- Header links also appearing in the footer
- custom walker to add iconfont to wp_nav_menu
- Creating Multiple Menus in the Thesis Theme?
- Turning WordPress Into full-featured website?
- Navigation won’t update to show full path to single post
- Nav walker bootstrap: Display 3rd level and 4th level in dropdown menu