Skip to content

Instantly share code, notes, and snippets.

@braddalton
Forked from studiopress/nav-extras.php
Last active April 16, 2019 14:43
Show Gist options
  • Save braddalton/33ad3b0295354ac65ff3a8b71395a408 to your computer and use it in GitHub Desktop.
Save braddalton/33ad3b0295354ac65ff3a8b71395a408 to your computer and use it in GitHub Desktop.
Add Search Form To Nav Menu In Genesis
add_filter( 'wp_nav_menu_items', 'add_search_genesis_menu', 10, 2 );
function add_search_genesis_menu( $menu, $args ) {
if ( 'primary' !== $args->theme_location )
return $menu;
ob_start();
get_search_form();
$search = ob_get_clean();
$menu .= '<li class="search">' . $search . '</li>';
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment