facetwp copy range to dropdown

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** create a range list facet with the ranges you need
** create a dropdown facet with any datasource, post type is good its just a placeholder
** change the code below to match your facet names
**/

add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘my_range_facet’ == $params[‘facet_name’] ) { // change ‘my_range_facet’ to the name of your range list facet
$params[‘facet_name’] = ‘dropdown_range’; // trick FacetWP into saving values into the other facet
} elseif ( ‘dropdown_range’ == $params[‘facet_name’] ) { // change ‘dropdown_range’ to the name of your dropdown facet in this and the above line
$params[‘facet_value’] = ”; // skip indexing
}
return $params;
}, 10, 2 );
{{/gist}}