Skip to content

Instantly share code, notes, and snippets.

  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anybodesign/df647d0a60d339c3773a1785c184a0b5 to your computer and use it in GitHub Desktop.
Accessible Facetwp dropdowns
function fs_add_dropdown_labels() {
?>
<script>
(function($) {
$(document).on('facetwp-loaded', function() {
$('.facetwp-dropdown').each(function() {
var facet_name = $(this).parent().attr('data-name');
var facet_label = FWP.settings.labels[facet_name];
$(this).attr('id', facet_name);
if ($('.facet-label[for="' + facet_name + '"]').length < 1) {
$(this).parent().before('<label class="facet-label" for="' + facet_name + '">' + facet_label + '</label>');
}
});
});
})(jQuery);
</script>
<?php
}
add_action( 'wp_head', 'fs_add_dropdown_labels', 100 );
@askwpgirl
Copy link

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment