Change submenu markup

The whole idea of a custom walker class is that you can customize the menu in detail. So, you can also leave the main menu as it is and build the submenus the way you give in the image. However, as Hareesh indicates in the comments, this does require quite a lot of customization, especially … Read more

Dynamically add sub menu items

I have found what I was looking for the function returns an id of the menu item needed. $my_menu_id = wp_update_nav_menu_item(4, 0, array(‘menu-item-title’ => __($my_menu_title), ‘menu-item-url’ => home_url(“https://wordpress.stackexchange.com/”.$url.”https://wordpress.stackexchange.com/”), ‘menu-item-parent-id’ => $my_menu_id, ‘menu-item-status’ => ‘publish’)); by knowing the menu id you can then create sub menus attached to the first menu item using the menu-item-parent-id

Where am I doing wrong in my theme menu?

Put the java script code in footer.php after wp_footer(); code like this <script type=”text/javascript”> jQuery(document).ready(function () { jQuery(“#primary_menu ul li”).hover(function () { jQuery(this).find(“ul”).stop().slideToggle(400); }); }); Remove the dolar sign is not compatible in WordPress in this case.

wp_nav_menu add class to child item with sub child

I have not tested this but it looks like you aren’t testing for $depth the way you need to be. This block: $classes[] = ($args->walker->has_children) ? ‘dropdown’ : ”; $classes[] = ($item->current || $item->current_item_anchestor) ? ‘active’ : ”; $classes[] = ‘menu-item-‘ . $item->ID; if( $depth && $args->walker->has_children ){ $classes[] = ‘dropdown-submenu’; } Should be something … Read more