Switching Primary Menu in Genesis Theme to Header Right on a Permanent Basis
I find that I always, well most of the time, use the header right widget area in Genesis for the Primary Menu of a site and create this menu by adding a Custom Menu to the Header Widget Area, whilst there is nothing wrong by doing it this way, there is a better way.
Here is a guide how to place the Primary Menu in the Header Widget Area by just moving its location there permanently via a Genesis hook. The benefit of doing this is that out of the box the location is set and you have more functionality with registered menus. So to go from this…
To this…
All the code goes in the themes function.php file
You can actually just add the remove_action and add_action functions at the beginning of the code and that alone will reposition the menu. The remove_action moves the menu away completely and the add_action adds it to the new location.
But I also want to modify the output of the menu by removing the wrap element it has by default. This is done by not declaring support for that element in the wrap list. The wrap list is originally declared in genesis/lib/init.php lines 62-64. So to leave one (or more out) just add the theme support without the element
add_theme_support( 'genesis-structural-wraps', array( 'header', 'menu-secondary', 'footer-widgets', 'footer' ) );
Add in some CSS
Add to your style.css which reverses the colors of the original menu and also sets the last link to have no padding so it sits flush right and aligns with the content below it.
.nav-primary { background-color:#fff; } .nav-primary li a{ color:#000; } .nav-primary a:hover, .nav-primary .current-menu-item > a { color:#666; } .nav-primary a:last-of-type { padding-right:0px; }