Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active May 29, 2019 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgee/c1ad4088cad40d201bcd010c1268a314 to your computer and use it in GitHub Desktop.
Save neilgee/c1ad4088cad40d201bcd010c1268a314 to your computer and use it in GitHub Desktop.
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