Skip to content

Instantly share code, notes, and snippets.

@mjepson
Created October 23, 2013 14:14
Show Gist options
  • Save mjepson/7119585 to your computer and use it in GitHub Desktop.
Save mjepson/7119585 to your computer and use it in GitHub Desktop.
Modify Canvas search form to only search WooCommerce products if you are on a WooCommerce page
<?php global $woo_options; ?>
<div class="search_main">
<form method="get" class="searchform" action="<?php echo home_url( '/' ); ?>" >
<input type="text" class="field s" name="s" value="<?php _e( 'Search...', 'woothemes' ); ?>" onfocus="if (this.value == '<?php _e( 'Search...', 'woothemes' ); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search...', 'woothemes' ); ?>';}" />
<?php if ( isset( $woo_options['woo_header_search_scope'] ) && $woo_options['woo_header_search_scope'] == 'products' && is_woocommerce_activated() && is_woocommerce() ) { echo '<input type="hidden" name="post_type" value="product" />'; } ?>
<button type="submit" class="icon-search submit" name="submit" value=""></button>
</form>
<div class="fix"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment