Created
November 3, 2017 08:11
-
-
Save phucdohong96/45d269506a0c250e8b1edf1d03ccf5b4 to your computer and use it in GitHub Desktop.
Form submit link to facetwp filter
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
<?php | |
//resource_home_filter_function | |
function resource_home_filter_function() { | |
ob_start(); | |
?> | |
<form method="get" action="/resources/" class="home_filter_form nobottommargin"> | |
<div class="select_filter"> | |
<select name='fwp_product_category' id='fwp_product_category' class='distributor_market' > | |
<option value='' selected='selected'>Document Categories</option> | |
<?php | |
$terms = get_terms( 'resource_category' ); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ | |
foreach ( $terms as $term ) { | |
$category_name = $term->name; | |
$category_slug = $term->slug; | |
echo '<option value="'.$category_slug.'">'.$category_name.'</option>'; | |
} | |
} | |
?> | |
</select> | |
</div> | |
<div class="select_filter"> | |
<select name='fwp_document_type' id='fwp_document_type' class='distributor_product' > | |
<option value='' selected='selected'>Document Type</option> | |
<?php | |
$terms = get_terms( 'resource_type' ); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ | |
foreach ( $terms as $term ) { | |
$category_name = $term->name; | |
$category_slug = $term->slug; | |
echo '<option value="'.$category_slug.'">'.$category_name.'</option>'; | |
} | |
} | |
?> | |
</select> | |
</div> | |
<input class="btn btn-lg" type="submit" value="Find Resources" /> | |
</form> | |
<script type="text/javascript"> | |
jQuery(function(){ | |
jQuery('form').submit(function(){ | |
jQuery('select').each(function(){ | |
if(jQuery(this).val()==''){ | |
jQuery(this).attr('disabled','disabled'); | |
} | |
}) | |
}) | |
}) | |
</script> | |
<?php | |
wp_reset_postdata(); | |
return ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment