Skip to content

Instantly share code, notes, and snippets.

@mgibbs189 mgibbs189/test.php
Last active Oct 5, 2015

Embed
What would you like to do?
facetwp_facet_filter_posts to override slider logic
<?php
function custom_slider_logic( $response, $params ) {
$facet = $params['facet'];
// Change the facet name
if ( 'YOUR_FACET_NAME' == $facet['name'] ) {
global $wpdb;
$values = $params['selected_values'];
$where = '';
// Min value - CUSTOMIZE ME
if ( !empty( $values[0] ) ) {
$where .= " AND CAST(facet_value AS DECIMAL(10,2)) >= '{$values[0]}'";
}
// Max value - CUSTOMIZE ME
if ( !empty( $values[1] ) ) {
$where .= " AND CAST(facet_display_value AS DECIMAL(10,2)) <= '{$values[1]}'";
}
$sql = "
SELECT DISTINCT post_id FROM {$wpdb->prefix}facetwp_index
WHERE facet_name = '{$facet['name']}' $where";
return $wpdb->get_col( $sql );
}
return $response;
}
add_filter( 'facetwp_facet_filter_posts', 'custom_slider_logic', 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.