Note: If you are looking to create a responsive mobile menu from the Primary Navigation Menu, jump on over here. If you are looking to create a responsive mobile menu from the Secondary Navigation Menu, jump on over here.
In my last tutorial on responsive mobile navigation menus I explained how to register a new navigation area for your Genesis 2.0 Child Theme and dedicate it as your Mobile Navigation Menu. Several people have contacted me wanting their Header Navigation to become Mobile friendly as the browser is collapsed or when viewed on mobile devices. While similar to my first tutorial, fewer steps are needed since we are using an existing Navigation.
It’s extremely important to use a good text editor. On the Mac I use the free TextWrangler editor by BareBones Software. Windows users may try the built-in Notepad or opt for free third party software like Notepad++.
Step 1 – Modify the Style Sheet
Since we are using Genesis Sample Theme, change the “@media only screen and (max-width: 767px)” query in the style sheet to “@media only screen and (max-width: 768px)” You are just changing the number from 767 to 768.
Click “view raw” in lower right of the box below. Copy/paste the CSS snippet into your child theme’s style.css file within the @media only screen and (max-width: 768px) query area. It is important that the new CSS follows the existing CSS within that area. Make sure it is placed before the last closing curly bracket “}” within that media query. Get this part wrong and everything will look funky so have that backup handy.
You can change the text “HEADER MENU \2630″ in the three locations of the CSS snippet to whatever you prefer. You may even opt to use a graphic instead of text. If nothing looks broken we can move forward. If the styling of your menu looks really bad at mobile widths or something is obviously out of place go back and make adjustments to eliminate any issues as going further will only complicate any problems by adding additional variables into the mix.
Create a folder named “js” using all lowercase letters. Using your text editor, create a blank file named “headermenu.js”. Use all lowercase letters and no spaces or hyphens in the name of this file. Paste the code snippet below within the headermenu.js file and save. Place the headermenu.js file within the js folder and upload that folder to the root of your child theme.
Click “view raw” in lower right. Copy/paste the code into the headermenu.js file.
Step 3 – Enqueue the Script
We are now going to enqueue the headermenu.js script so that your child theme can take advantage of it. Open up your functions file within your child theme and paste the following code within that file. Usually it is safe to paste below any existing code within that file.
Click “view raw” in lower right. Copy/paste the code below into your child theme’s function file.
Step 4 – Get the Menu Name Right
Refresh your site and you should have a fully functioning Header Navigation Menu that transforms into a mobile friendly menu when viewing with small browser widths or mobile devices. The Header Navigation menu should behave similar to what you see here http://bradpotter.com/themes/genesis20/
What if I wanted to do this to the Primary or Secondary Navigation Menu instead? There’s a tutorial for that. Check the links below.
I am getting a lot of requests to create a Mobile Navigation Menu plugin for Genesis and it is something I am working on. However, I wanted to first empower you to implement a Mobile Navigation solution that best fits your theme design and layout. It would take a fairly complicated plugin (that may or may not be maintained) to solve everyone’s needs.
Sometimes a website may have a Header Navigation Menu with a lot of sub menu items which can cause the menu to be rather tall. I am experimenting with 3 different options that allow you to collapse sub items in order to address that issue. Stay Tuned!