Last active
April 19, 2018 16:27
-
-
Save djrmom/3286304a09092df8fc4d6086b605826a to your computer and use it in GitHub Desktop.
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 | |
/** | |
* filter html for sort output to output radio buttons | |
*/ | |
add_filter( 'facetwp_sort_html', function( $html, $params ) { | |
$html = ''; | |
foreach ( $params['sort_options'] as $key => $atts ) { | |
$html .= '<input type="radio" name="custom-sort" value="' . $key . '">' . $atts['label'] . '<br>'; | |
} | |
return $html; | |
}, 10, 2 ); | |
/** | |
* add js to custom handle selections of sort radio button | |
*/ | |
add_action( 'wp_head', function() { | |
?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
$('input[type=radio][name=custom-sort]').change(function () { | |
FWP.extras.sort = $(this).val(); | |
FWP.soft_refresh = true; | |
FWP.autoload(); | |
}); | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment