Created
November 17, 2020 16:25
-
-
Save BryanBarrera/2fe101f2c11c5ddbee7e2034c8511b9e to your computer and use it in GitHub Desktop.
Check if FacetWP Facet has selection and add a claass
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
<script> | |
(function($) { | |
/** | |
* check if a facet exists and has value(s), change 'news_categories' to name of the facet being checked | |
*/ | |
$(document).on('facetwp-loaded', function() { | |
if (FWP.facets['news_categories'] == 'awards') { | |
$('.news--container').addClass('is-awards') | |
} else if (FWP.facets['news_categories'] == 'in-the-news') { | |
$('.news--container').addClass('is-in-the-news') | |
} else if (FWP.facets['news_categories'] == 'press-reases') { | |
$('.news--container').addClass('is-press-releases') | |
} | |
}); | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment