Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ever wanted to add a widget area before the .menu <ul> of the Genesis menus? With this simple gist you can do just that. Included are some comments to allow you to change it to use the primary menu or move the widget area to after the </ul> of the .menu. This gist assumes you have made a sidebar with the ID "subnav-left"
//You could use genesis_do_nav to target the primary menu
add_filter( 'genesis_do_subnav', 'child_do_subnav_widget', 10, 2 );
/** Adds widget area before the .menu on #subnav */
function child_do_subnav_widget( $subnav_output, $subnav ){
genesis_widget_area( 'subnav-left', array(
'before' => '<div class="subnav-left widget-area">',
'after' => '</div>', //required for HTML5 enabled themes
) );
$widget_area = ob_get_clean();
// you could use $subnav . $widget_area to put the widget area after the </ul> of .menu
return str_replace( $subnav, $widget_area . $subnav, $subnav_output );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.