It would be easier to add this on a menu link. The attributes for each link pass through the nav_menu_link_attributes
filter.
You should be able to use it to add a custom one, along the lines of (not tested):
add_filter( 'nav_menu_link_attributes', function( $atts, $item ) {
// check if $item is what you need
$atts['data-slug'] = 'something';
return $atts'
}, 10, 2);
To change the whole list items you would have to use more general walker_nav_menu_start_el
filter, which only passes string you would have to cut up more messily.
Related Posts:
- Get menu item slug
- How to get the post name (slug) from the item ID when traversing the navbar?
- Custom walker with hashes instead of links (one-page layout)
- WordPress Menu Walker: add #hashes to child page links (only)
- How to get or know the slug of home.php
- Swap out a page that is a parent to a many many pages
- how to add permalink/slug to wordpress custom link menu item
- Unregister Nav Menu from Child-Theme
- Deleted pages are NOT removed from custom menus?
- Keeping parent menu items active in child pages
- Add Page ID class to nav menu items
- Way to bulk delete menu items in new 3.x Appearance > Menus system?
- Pass a parameter to a menu walker
- Menu is not visible in appearance
- WordPress nav_menu_link_attributes Not Working
- Customize the menu by adding items
- Organizing by super-categories (or nested categories)?
- Nav Menu and display post count
- Adding first and last class to Menu on top level only
- wp_nav_menu log in/out link?
- How do I get my wp_nav_menu single category page to highlight the parent?
- Accesibility problems with dropdown menus in twentyten theme or others
- Theme menu in Admin Panel
- How to target children of child pages
- How to insert custom code into wp_nav_menu structure?
- How to add custom menu item on plugin activation?
- Outside the loop, how can I echo the current page’s menu title?
- WordPress Admin Bar Covering & Overlapping Fixed Menu Header [closed]
- getting parent page id when using custom menu.
- Use menu class in walker function
- Menu link to all posts (all categories included)
- Change name & menu_name for Profile in the default menu, w/o altering core files?
- wp-menu ‘automatically add custom taxonomy terms’ like it does for pages? [closed]
- SlickNav – Google Lighthouse Accessibility issue for collapsed menu button
- Creating a navigation menu to see where you are on your website
- How I can overlap my menu in my header picture
- current-menu-item class in CSS
- Put class on instead li
- Tiles as a navigation
- Custom format nav menu only using div and a
- How to make the Primary Menu stay the same in the PC and mobile versions of the Twenty Sixteen theme
- How to add notifcations to front-end menu for users when they recieved replies?
- Page content loading issue using Walker_Nav_Menu
- Links do not open from click, only in new tab [closed]
- Default menu editor with automatic page list
- Switch from hover to click on Twenty Twelve Menu
- Can I have custom post types in “Add menu items” on in the Admin > Appearance > Menu
- Add a custom class to nav li item
- Adding anchors in WordPress Menus
- magic “MENU” button under Twenty Twelve theme
- Remove first separator in wp_nav_menu
- wp_nav_menu check both hierarchy fail?
- How can I make a WordPress sub-menu with a top-level that isn’t clickable?
- How do add a menu with levels within page [closed]
- Get parents child pages
- menu-item class missing on wordpress menu
- how to add home icon instead of text in wordpress menu
- Active class to current link
- Making pages in a menu appear conditionally
- Modify the output of wp_nav_menu in a very specific way?
- Display pictures instead of text in menus
- how to check if given page is active page
- How to add social buttons like facebook and twitter in the footer of a theme?
- WordPress Menu – creating a fake link [closed]
- How to add an archive page to WordPress menus (nav_menu)?
- Add div content to my already existing menu
- Add category label for appearance > menus items
- Custom items for Menus
- dot.com/car1 does work, but dot.com/transport/car1 doesn’t work
- calling JS to custom menu design
- WP pages content is missing in frontend
- Active menu item state on all menu items
- Dashicons not showed for admin menu
- How to select particular menu position in wordpress?
- Menus not visible in Appearance after being registered
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Cannot add home page url to menu with #
- Accidental reverse order of menu items in one menu
- Having an issue with wp_nav_menu displaying custom navigation
- Add dynamic content block to nav section generated by custom walker
- Customizing label/title output of admin nav_menu selecter
- Extend Individual Menu on Page Function to individual Submenue on Page Function?
- Menu administration, how to allow special charachters
- How to avoid website url appending problem in wp site?
- Create custom page and custom menu
- Get first menu item of custom menu
- How can I modify wp_nav_menu with walker?
- menu items outside of blog
- Walker for menus
- Bought custom navigation menu from codecanyon, how to change feature.php?
- Custom menu linking to page not found
- How to insert date in topNav
- Change sub-menu css class
- How to add an tag when a menu item is a dropdown(or has a sub-menu) [duplicate]
- Remove “Next Post” in nav_menu
- How to display a submenu as a popup when clicking a button?
- Menu not Showing on Mobile or While the page is shrinked
- How do i add logo in wordpress studiopress (glam theme)?
- Add A Menu Item To A WP_Nav_Menu Navigation via PHP Function
- Add acf custom fields so sub item in menus