Skip to content

Instantly share code, notes, and snippets.

@topleague
Last active August 16, 2019 14:13
Show Gist options
  • Save topleague/8bc2a415eb7cf4305c1179a6a9a3c56d to your computer and use it in GitHub Desktop.
Save topleague/8bc2a415eb7cf4305c1179a6a9a3c56d to your computer and use it in GitHub Desktop.
Search Bar in Primary Menu in Genesis Version: 2.6.0
/* Optimize Search Bar in Primary Menu */
[type=search] {
width: auto;
}
input[type="submit"] {
font-size: 19px;
}
.right.search, .search-bar {
float: right;
}
.search-form input[type="submit"] {
margin-top: 0;
}
.genesis-nav-menu .menu-item {
padding: 7px;
}
/* Adjustment for Mobile Devices (Add this code snippet to
the appropriate media queries on your stylesheet) */
@media only screen and (max-width: 1023px) {
.genesis-nav-menu .menu-item {
padding: 0;
}
.right.search, .search-bar {
float: left;
}
}
// Add a Search Bar to PRIMARY Navigation Menu
add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
function theme_menu_extras( $menu, $args ) {
if ( 'primary' !== $args->theme_location )
return $menu;
$menu .= '<li class="search-bar">' . get_search_form( false ) . '</li>';
return $menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment