Skip to content

Instantly share code, notes, and snippets.

@mgibbs189 mgibbs189/test.php
Created Dec 21, 2015

Embed
What would you like to do?
FacetWP - modify date_range facet to find posts on a certain day
<?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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.