FacetWP – modify date_range facet to find posts on a certain day

mgibbs189

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

function fwp_match_exact_day( $return, $params ) {
$facet = $params[‘facet’];
$values = $params[‘selected_values’];

if ( ‘YOUR_FACET_NAME’ == $facet[‘name’] ) {
global $wpdb;

$where = ”;
if ( ” != $values[0] ) {
$where .= ” AND LEFT(facet_value, 10) = ‘{$values[0]}'”;
}

$sql = ”
SELECT DISTINCT post_id FROM {$wpdb->prefix}facetwp_index
WHERE facet_name = ‘{$facet[‘name’]}’ $where”;
return $wpdb->get_col( $sql );
}
return $return;
}
add_filter( ‘facetwp_facet_filter_posts’, ‘fwp_match_exact_day’, 10, 2 );
{{/gist}}