FacetWP – pre-select a facet on load

mgibbs189

{{gist file=”test.js” lang=”javascript”}}
<?php

// Add to functions.php
function fwp_preselect_choice() {
?>
<script>
(function($) {
$(document).on(‘facetwp-refresh’, function() {
if (! FWP.loaded && ” == FWP.build_query_string()) {
FWP.facets[‘categories’] = [‘rvparks’];
}
});
})(jQuery);
</script>
<?php
}
add_action( ‘wp_head’, ‘fwp_preselect_choice’, 50 );

{{/gist}}