Last active
April 21, 2018 00:21
-
-
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.
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
/** | |
* 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