Skip to content

Instantly share code, notes, and snippets.

@wurwal
Created April 3, 2020 17:41
Show Gist options
  • Save wurwal/c3cb4d7308154d9e623faf9457837b7e to your computer and use it in GitHub Desktop.
Save wurwal/c3cb4d7308154d9e623faf9457837b7e to your computer and use it in GitHub Desktop.
FacetWP - print out selected facets to a div with id 'output' in a comma separated line dynamically
jQuery(document).on('facetwp-loaded', function() {
var facetname = "facet-name-here";
var data = FWP.facets[facetname];
var string = data.toString();
var stringFormatted1 = string.replace(/-/g, ' ');
var stringFormatted2 = stringFormatted1.replace(/,/g, ", ");
if (string) {
document.getElementById("output").innerHTML = "<p><span class='primary bold'>" + facetname + "selected</span>: <i>" + stringFormatted2; + "</i></p>"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment