If you want to add a custom data
attributes to the menu that’s generated by wp_nav_menu
function. You can use the nav_menu_link_attributes
filter to add the desired attributes to the <a>
elements.
function add_menu_atts( $atts, $item, $args ) {
$atts['data-hover'] = $atts['title']; // add data-hover attribute
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_menu_atts', 10, 3 );
Related Posts:
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to modify mobile nav menu text in theme
- how to changes mobile menu toggle breakpoint in WordPress
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- Adding first / last CSS classes to menus
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- Displaying Logged-In User Name in WordPress Menu
- WordPress Shortcode and Dynamic CSS
- Multiple pages on one with different HTML
- Logout and redirect using the WP Menu
- Minify HTML, CSS, JS with PHPWee?
- How to display a value from a radio button in the options menu in wordpress
- How can I add a custom class to only nav sub-menu > li > a items in WordPress?
- items_wrap not working
- Style wp_page_menu() items
- wp nav menu: add attributes to menu items [duplicate]
- Shortcode content output but not in correct place
- An unwanted inline style is added to my body tag
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- How can I hide Home in my menu in a specific page?
- Missing sidebar parameter “fix” – before_content
- How Display Posts on category
- Change Navigation Bar based on logged in or not
- Multiple WordPress Menus that will only display all pages
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- Customize position of social icons in upme plugin [closed]
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Wrapping a Sidebar within
- Add Codepen animation as Preloader to WordPress
- Add data-id attribute to child page links
- Add login hyperlink to secondary navigation menu
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Where can I find the inline-css of my theme header?
- Highlight the links without using dropdown
- Need help removing […] after excerpt
- Link to page with posts of specific type
- Extend Menu Walker Output
- Nav-Menu not showing up
- Why can’t I add a custom image in my navigation?
- conditional: if is page, and all subpages
- wp nav menu: show submenu below li item
- Remove the Tag from wp_nav_menu
- Styling an “active” link outside of WordPress default menu
- Adding a navigation page state to individual blog and portfolio pages
- Displaying images outside the content
- Background image no longer fits to screen now that project is in php files
- Add other class content with reference class value
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- PHP function for horizontal Woocommerce thumbnails and badges
- I can’t go to the page archive-{post_type}.php
- How to set Nav as a default menu in wordpress
- Help me I cannot link my font-awesome to my WordPress Theme. I have my font-awesome folder already in my project
- Drop down question
- WP Website is shown in HTML
- Can’t display anything through homepage text editor
- How to find and delete a menu item in php?
- WordPress Slider is not working
- How to display post meta bellow every posts
- How to let mobile navigation menu close when link is clicked?
- how to add functions to my function.php using a child theme?
- Redirect User when they click Menu Option
- How to create a sub-page of sub-page?
- Target a specific container to style on WordPress storefront theme
- How to include different html tags in the header for different pages?
- user update profile for custom code
- Vertical Menu for one page only
- How limit the width of a fixed menu-bar on scroll?
- Font-Family does not looks like how it should be [closed]
- Where to find the html for WordPress site? [closed]
- wp nav menu without label
- Add extra markup to WP menus
- Show contact 7 form in popup
- WordPress – Image href for home menu nav not working
- How Can I Center the Logo in the Navigation Menu? [closed]
- Add the “.current-menu-item” class to tag?
- featured post as div background
- WP_Nav Highlight Parent Issue
- Cant get theme to change footer color through theme customizer
- How to change the menu color
- Nav Menu Display
- How do I modify the with wp_nav_menu()
- How to add or remove borders in navigation menu?
- How to customize posts in WordPress by using HTML and CSS?
- WP_Query not returning results
- Open WordPress Page from selected option dropdown
- Header location [closed]
- How do I link the side images?
- Parse error: syntax error, unexpected ‘}’ in
- Sorting Problem
- How to create a container in php then customise it in CSS
- Custom HTML/CSS Theme into WordPress – SEO considerations
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- Nav menù doesn’t display selected pages
- How to create different templates for woocommerce single-product.php?