Created
April 3, 2020 17:41
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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