Support » Plugin: Shortcake (Shortcode UI) » Select2 conflict with Advanced Custom Fields

  • Hello,
    In version 0.7.0, there was introduced some conflict of javascripts with Advanced Custom Fields regarding Select2 library. When I include field, which has Select2, like post_select, for example:

    	'label' => 'Page link',
    	'type' => 'post_select',
    	'attr' => 'post',
    	'query' => array( 'post_type' => array( 'page', 'blog' ) )

    I get modal window, but without any fields in it.

    In console, I get this error:
    Uncaught Error: Option 'multiple' is not allowed for Select2 when attached to a <select> element.

    Error is initiated in shortcode-ui.js on line 1762.

    Thank you for useful plugin, Jakub Klapka

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’ve got the same issue. As a temp fix you can disable ACF loading select2:

    add_filter('acf/settings/enqueue_select2', '__return_false');

    This might give new issues in ACF itself, but I’ve not extensively tested this.

    In ACF 5.5, they have added filter, which would resolve it in much better way.

    add_filter( 'acf/settings/select2_version', function( $version ) {
    	return 4;

    More on that on .

    I’ve spent much of the day trying out this and a few other apparent solutions to this conflict, with no luck, but at last I have a solution. This is with (as of now) the latest versions of each: WordPress 4.7.4, ACF PRO 5.5.13, and Shortcake 0.7.2.

    What works for me is to get Shortcake to change its handle for Select2. Fortunately, Shortcake includes a SELECT2_NOCONFLICT constant that you can use to get it to change the handle. But the check for that is called on the init hook with a priority of 5, so you need to define the constant earlier than that.

    Here’s the code that is working for me:

    add_action('init', function() { define('SELECT2_NOCONFLICT', true); }, 1);

    Thanks @room34 – this solved an issue with use of the Select2 library with Shortcake and Woocommerce Smart Coupons.

    • This reply was modified 1 year, 4 months ago by  FLOQ Design.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Select2 conflict with Advanced Custom Fields’ is closed to new replies.