Last active
February 24, 2016 01:01
-
-
Save frankschrijvers/3a1fd0ae71e05adb445f to your computer and use it in GitHub Desktop.
Add WooCommerce Search Box to navigation Genesis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_nav_menu_items', 'wpstudio_add_woo_search', 10, 2 ); | |
/** | |
* Add WooCommerce cart to primary navigation Genesis | |
* @author Frank Schrijvers | |
* @link https://www.wpstud.io/add-woocommerce-cart-to-genesis-navigation/ | |
*/ | |
function wpstudio_add_woo_search( $menu, $args ) { | |
//* Change 'primary' to 'secondary' to add the woocommerce search to the secondary navigation menu | |
if ( 'primary' !== $args->theme_location ) | |
return $menu; | |
$form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '"> | |
<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'Search for products', 'woocommerce' ) . '" /> | |
<input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search', 'woocommerce' ) .'" /> | |
<input type="hidden" name="post_type" value="product" /> | |
</form>'; | |
$menu .= '<li class="searchbox">' . $form . '</li>'; | |
return $menu; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment