Skip to content

Instantly share code, notes, and snippets.

@mattradford
Last active April 21, 2018 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattradford/fb1896d707ba6e1333fbf9c5351caa22 to your computer and use it in GitHub Desktop.
Save mattradford/fb1896d707ba6e1333fbf9c5351caa22 to your computer and use it in GitHub Desktop.
Set the number of choices selected at which "{n} selected" will display. is_tax conditional left as an example.
/**
* Set {n} selected text to show after 1 selection, on all facets
*/
function td_facetwp_selected() {
if ( is_tax() ) {
?>
<script>
(function($) {
$(function() {
if ('undefined' !== typeof FWP) {
wp.hooks.addFilter('facetwp/set_options/fselect', function(opts, data) {
opts.numDisplayed = 1;
return opts;
});
}
});
})(jQuery);
</script>
<?php
}
}
add_filter( 'wp_head', 'td_facetwp_selected', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment