Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active August 24, 2020 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/5795cee7271f1be98fceb2563fa91f03 to your computer and use it in GitHub Desktop.
Save djrmom/5795cee7271f1be98fceb2563fa91f03 to your computer and use it in GitHub Desktop.
facetwp copy range to dropdown
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment