Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Style Default Select Form Elements Using Selectize JS
<?php // <~ don't add me in
add_action('wp_enqueue_scripts', 'my_select_dropdown');
function my_select_dropdown() {
if( is_shop() || is_product_category() ) {
wp_enqueue_style( 'select2');
wp_enqueue_script( 'selectinit', get_stylesheet_directory_uri() . '/js/select2-init.js', array( 'selectWoo' ), '1.0.0', true );
}
}
<?php // <~ don't add me in
add_action('wp_enqueue_scripts', 'my_select_dropdown');
function my_select_dropdown() {
wp_enqueue_script( 'select2js', get_stylesheet_directory_uri() . '/js/select2.min.js', array( 'jquery' ), '4.0.6', true );
wp_enqueue_style( 'select2css', get_stylesheet_directory_uri() . '/css/select2.min.css' , array(), '4.0.6', 'all' );
wp_enqueue_script( 'selectinit', get_stylesheet_directory_uri() . '/js/select2-init.js', array( 'select2js' ), '1.0.0', true );
}
jQuery(document).ready(function($) {
$('.woocommerce-ordering select').select2(); // Add your target select field
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.