Skip to content

Instantly share code, notes, and snippets.

@hirejordansmith
Created March 10, 2018 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirejordansmith/c8d41a23f6538817e1d2b7db321ace57 to your computer and use it in GitHub Desktop.
Save hirejordansmith/c8d41a23f6538817e1d2b7db321ace57 to your computer and use it in GitHub Desktop.
How to modify the WooCommerce Product Search Form
add_filter( 'get_product_search_form' , 'woo_custom_product_searchform' );
function woo_custom_product_searchform( $form ) {
$form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '">
<div>
<label class="screen-reader-text" for="s">' . __( 'Enter Keyword or Product Number', 'woocommerce' ) . '</label>
<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'Enter Keyword or Product Number', 'woocommerce' ) . '" />
<input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search', 'woocommerce' ) .'" />
<input type="hidden" name="post_type" value="product" />
</div>
</form>';
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment