__( 'Header Home Menu', 'apelleuno' ), 'central-home-menu' => __( 'Home Menu', 'apelleuno' ), 'top-primary' => __( 'Primary Menu', 'apelleuno' ), ) ); } add_action( 'init', 'register_menu_home' ); function add_link_atts($atts,$item, $args ) { if( $args->theme_location == 'header-home-menu' ) { $atts['class'] = "nav-link"; } if( $args->theme_location == 'central-home-menu' ) { $atts['class'] = "c-content-nav__link js-contentNavListItem"; } if( $args->theme_location == 'top-primary' ) { $atts['class'] = "nav-link "; } return $atts; } add_filter( 'nav_menu_link_attributes', 'add_link_atts', 10, 3); // Add CSS class to children menu item on WordPress add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' ); function add_menu_parent_class( $items ) { foreach ( $items as $item ) { if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) { $item->classes[] = 'dropdown-item'; } } return $items; } add_filter( 'nav_menu_link_attributes', 'add_class_to_items_link', 10, 3 ); function add_class_to_items_link( $atts, $item, $args ) { // check if the item has children $hasChildren = (in_array('menu-item-has-children', $item->classes)); if ($hasChildren) { // add the desired attributes: $atts['class'] = 'nav-link dropdown-toggle'; $atts['data-toggle'] = 'dropdown'; $atts['data-target'] = '#'; } return $atts; } class Apelle_Walker_Nav_Menu_primary extends Walker_Nav_Menu { function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent