facetwp auto-check facet

djrmom

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

function fwp_update_facets() {
?>
<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
if ( ‘trainings-finden’ == FWP_HTTP.uri ) {
if ( FWP.facets[‘standort’].indexOf(“aarau”) > -1 && ! ( FWP.facets[‘standort’].indexOf(“flexibel”) > -1 ) ) {
FWP.is_reset = true;
FWP.facets[‘standort’].push(“flexibel”);
FWP.refresh();
}
}
});
})(jQuery);
</script>
<?php
}
add_action( ‘wp_head’, ‘fwp_update_facets’ );
{{/gist}}