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?
- Second Navigation inside header
- 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
- Show post in slider
- 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
- how to remove metadata from the posts of my blog?
- Menu Limitations
- 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
- How to style one item from main navigation?
- 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
- Website completely messes up when logging out
- Need help removing […] after excerpt
- How can I use custom menus with a Bootstrap WordPress theme?
- Link to page with posts of specific type
- Extend Menu Walker Output
- Nav-Menu not showing up
- Custom navigation menu with awsAccordion
- 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
- 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
- Trying to customize wordpress drop down categories
- 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
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- ‘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?
- Editing stylehseet url in head section of WordPress
- separating column the variations from the add to cart button woocommerce
- How can we upload custom page files?