Adding attribute to menu items
-
Good evening everybody. I need to add a custom attribute to my menu items.
This is what I believe I have to do… but nothing is added.
add_filter( 'nav_menu_link_attributes', 'add_role_attribute_to_menu' ); function add_role_attribute_to_menu( $atts ) { $atts['role'] = 'button'; return $atts; }
I’m using WP 5.6 and Astra free theme.
What’s the matter? Maybe I have to include the add_filter inside another call?
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Adding attribute to menu items’ is closed to new replies.