Skip to content

Instantly share code, notes, and snippets.

@NicktheGeek
Last active December 10, 2015 22:38
Show Gist options
  • Save NicktheGeek/4503511 to your computer and use it in GitHub Desktop.
Save NicktheGeek/4503511 to your computer and use it in GitHub Desktop.
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"
<?php
//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 ){
ob_start();
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