Skip to content

Instantly share code, notes, and snippets.

@goliver79
Created February 5, 2014 14:35
Show Gist options
  • Save goliver79/8824907 to your computer and use it in GitHub Desktop.
Save goliver79/8824907 to your computer and use it in GitHub Desktop.
[WOOCOMMERCE] Modify navigation search form
<?php
/**
* modify search form
* - "search for products" string translate
* - language for qTranslate
*/
add_action( 'after_setup_theme', 'lgpd_change_search_nav' );
function lgpd_change_search_nav(){
remove_action('woo_nav_before', 'wootique_header_search');
add_action('woo_nav_before', 'lgpd_wootique_header_search');
}
function lgpd_wootique_header_search() {
global $woo_options;
?>
<div id="search-top">
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo home_url() . "?lang=" . qtrans_getLanguage(); ?>">
<label class="screen-reader-text" for="s"><?php _e('Search for:', 'woothemes'); ?></label>
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" class="field s" placeholder="<?php _e('Search for products', 'my_text_domain'); ?>" />
<input type="image" class="submit btn" name="submit" value="<?php _e('Search', 'woothemes'); ?>" src="<?php echo get_template_directory_uri(); ?>/images/ico-search.png">
<!-- @goliver hidden field for qTranslate -->
<input type="hidden" name="lang" value="<?php echo qtrans_getLanguage(); ?>">
<?php if ($woo_options['woo_header_search_scope'] == 'products' ) { echo '<input type="hidden" name="post_type" value="product" />'; } else { echo '<input type="hidden" name="post_type" value="post" />'; } ?>
</form>
<div class="fix"></div>
</div><!-- /.search-top -->
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment