<?php
add_action( 'wp_head', function() {
?>
<script>
(function($) {
document.addEventListener('facetwp-loaded', function() {
var classList = document.body.className.split(/\s+/);
for (var i = 0; i < classList.length; i++) {
if (classList[i].includes("-community")) {
$('body').removeClass( classList[i] );
}
}
if ( 'undefined' !== typeof FWP.facets['state'] && 1 === FWP.facets['state'].length ) {
$('body').addClass( FWP.facets['state'][0] + '-community' );
}
});
})(jQuery);
</script>
<?php
}, 100 );