Skip to content

Instantly share code, notes, and snippets.

@liranop
Last active January 19, 2024 10:04
Show Gist options
  • Save liranop/d7c6071dc3d68d166d96712fbbbc90d3 to your computer and use it in GitHub Desktop.
Save liranop/d7c6071dc3d68d166d96712fbbbc90d3 to your computer and use it in GitHub Desktop.
add select2 to jetsmartfilter select (php code snippet + js script)
<script>
(function() {
jQuery(document).on('jet-smart-filters/inited', function( initEvent ) {
// Initialize select2 on the select field
jQuery('.jet-select__control').select2({
placeholder: 'Search...',
width: '100%',
});
});
})(jQuery);
</script>
function enqueue_select2_scripts() {
// Enqueue Select2 CSS
wp_enqueue_style('select2-css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css');
// Enqueue Select2 JavaScript
wp_enqueue_script('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js', array('jquery'), '', true);
}
add_action('wp_enqueue_scripts', 'enqueue_select2_scripts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment