Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created October 16, 2020 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/7cd4e3f10dfbbfa98e2abc9ad5f2087c to your computer and use it in GitHub Desktop.
Save djrmom/7cd4e3f10dfbbfa98e2abc9ad5f2087c to your computer and use it in GitHub Desktop.
facetwp fselect label
/**
* Use a default label in the open fselect dropdown different from the default shown when closed
* change facetwp-facet-product_categories to name of your facet and Custom Label to the label you want to use
**/
add_action( 'wp_head', function() { ?>
<script>
(function($) {
$(function() {
if ('object' !== typeof FWP) {
return;
}
FWP.hooks.addAction('facetwp/loaded', function() {
console.log('test');
$( '.facetwp-facet-product_categories .fs-option:first-of-type .fs-option-label' ).text( 'Custom Label' );
}, 100 );
});
})(jQuery);
</script>
<?php }, 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment