FacetWP – index multiple dates from a single string

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// here is the code you need
// input: “May 18, 2017 to May 24, 2017”
add_filter( ‘facetwp_index_row’, function( $params, $class ) {
if ( ‘date_range_muli’ == $params[‘facet_name’] ) {
$dates = explode( ‘ to ‘, $params[‘facet_value’] );
$params[‘facet_value’] = date( ‘Y-m-d’, strtotime( $dates[0] ) );
$params[‘facet_display_value’] = date( ‘Y-m-d’, strtotime( $dates[1] ) );
}
return $params;
}, 10, 2 );
{{/gist}}