facetwp preselect

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

add_filter( ‘facetwp_preload_url_vars’, function( $url_vars ) {
if ( ‘demo/cars’ == FWP()->helper->get_uri() ) {
if ( empty( $url_vars[‘make’] ) && empty( $url_vars[‘other_facet’] ) ) {
$url_vars[‘make’] = array( ‘audi’ );
$url_vars[‘other_facet’] = array( ‘something’ );
}
} elseif ( ‘demo/otherpage’ == FWP()->helper->get_uri() ) {
if ( empty( $url_vars[‘make’] ) && empty( $url_vars[‘other_facet’] ) ) {
$url_vars[‘make’] = array( ‘audi’ );
$url_vars[‘other_facet’] = array( ‘something’ );
}
}
return $url_vars;
} );
{{/gist}}