Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
DIVI WooCommerce search
function my_search_form( ) {
$post_type = isset($_GET['post_type'])?$_GET['post_type']:'';
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="screen-reader-text" for="s"><?php _x( 'Keresés:', 'label' ); ?></label>
<select class="searchfor">
<option value="" <?php selected( $post_type , '' ); ?>>Weboldalon</option>
<option value="product" <?php selected( $post_type , 'product' ); ?>>Termékek között</option>
<input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />
<input type="hidden" class="post_type_search" name="" value="product" />
<input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
$(document.body).on('change', '.searchfor', function(){ = (this.value == 'product')?'post_type':'';
return ob_get_clean();
add_filter( 'get_search_form', 'my_search_form', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.