djrmom

{{gist file=”radio-sort.php” lang=”php”}}
<?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 );
{{/gist}}