facetwp facetwp_wpdb_sql filter

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?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 );
{{/gist}}