jenny-r
6/20/2018 - 10:32 PM

facetwp facetwp_wpdb_sql filter

facetwp facetwp_wpdb_sql filter

<?php

/** simple example of adding additional values to selected **/
add_filter( 'facetwp_wpdb_sql', function( $sql, $facet ) {
    if ( 'product_categories' == $facet['name'] ) {
        $sql = preg_replace( '/facet_value IN \(([^\)]+)\)/i', 'facet_value IN ( ${1}, \'clothing\')', $sql );
    }
    return $sql;
}, 10,2 );