Many Genesis Framework users opt to use the Custom Menu Widget in the Header Right Widget Area instead of the standard primary and/or secondary menu locations built into your theme if they are supported at all. The problem you will encounter with the Custom Menu Widget is that it does not generate a mobile responsive menu. This can be a big problem, especially with the vast numbers of mobile users accessing our sites. In fact, I've seen numerous questions in forums asking how to make the Custom Menu Widget mobile responsive. The questions I've reviewed have remained unanswered.
This tutorial is a direct result of a requirement for one of my clients, Blue Olive Strategic Solutions. I recently built a new child theme for one of Blue Olive's customers, American RX. The design required me to place the primary navigation menu in the Custom Menu Widget in the Header Right area. Blue Olive asked for a typical mobile responsive hamburger menu when viewed on small mobile screens. It took a while, but I solved the problem. This tutorial will teach you how to make the custom menu widget mobile responsive. It may not solve your problem completely, but it will certainly get you on the right track.
The crux of the problem lies in the fact that Genesis responsive menus require that the menu be assigned to the primary and/or secondary theme locations. When the markup is created, the HTML wrappers have the class of nav-primary or nav-secondary. It's relatively easy to hook into the primary or secondary navigation areas. But when the menu is generated in the Custom Menu Widget, it has a class called nav-header. There aren't any built-in hooks for the nav-header class, at least none that I can find.
Before we get into the code, there are a few things that need explanation. First, I use the Dynamik Website Builder from CobaltApps to build my child themes. The Dynamik Website Builder generates its own code to create mobile responsive menus. I generally choose a vertical toggle style menu. When using the primary and secondary menu locations, the generated code, inserts a section of div tags before the nav-primary and nav-secondary elements. These div tags are what drives the menu toggle.
Second, I am not providing the code generated by Dynamik Website Builder. There are dozens of examples and plenty of source code available for mobile responsive menus. You've probably already gotten your own favorite code that you use with your sites. This tutorial will point you in the right direction for integrating your own code so the Custom Menu Widget is mobile responsive.
Third, I am assuming that you do not have a menu assigned to your theme's primary location.
With those points out of the way, here's the code:
What we're doing here is to replace the genesis_do_header function with our own custom header function. This function is essentially the core genesis_do_header function with some slight modifications. What makes this code work for my theme is the last function, vmf_genesis_header_menu_wrap. The native genesis_header_menu_wrap function does one thing, it creates the HTML markup for any menu assigned to the Custom Menu Widget in the Header Right Area. The following is the code for the native genesis_header_menu_wrap function.
This is where the nav-header markup is created. In the customized code, I added some additional markup required by the Dynamik Website Builder code and also changed the menu markup from nav-header to nav-primary. This works great on the client's site. I hope it helps you move in the right direction with your theme.
Thank you! I been looking for this! I hope it actually is exactly what I been looking for. I got a navigation in my header widget are on the right and just can’t seem to get the responsive menu to show correctly without the header nav dropping down on the actual content area of the page and the messing up the whole design of the site.