How to add a data attribute to a WordPress menu item
Specifically editing the code you provided in the original question: add_filter( ‘nav_menu_link_attributes’, ‘wpse121123_contact_menu_atts’, 10, 3 ); function wpse121123_contact_menu_atts( $atts, $item, $args ) { // The ID of the target menu item $menu_target = 123; // inspect $item if ($item->ID == $menu_target) { $atts[‘data-toggle’] = ‘modal’; } return $atts; }