Open gyrus opened 3 years ago
Hi @Djennez. Any news on this? We're experiencing this issue too.
Hi guys, as a quick workaround, I adapted a solution found for an identical problem between a version of ACF PRO and Yoast (original post here: https://support.advancedcustomfields.com/forums/topic/acf-yoast-seo-conflict-issue/ ).
Here is my adapted code, you want to add it in your functions.php or similar:
function fixYoastAndCMBmultiselect() {
wp_deregister_script( 'yoast-seo-select2' );
wp_dequeue_script( 'yoast-seo-select2' );
wp_enqueue_script( 'yoast-seo-select2', '/wp-content/plugins/cmb2-fields-select2/js/select2.min.js', [ 'jquery' ]);
}
add_action( 'admin_enqueue_scripts', 'fixYoastAndCMBmultiselect', 99 );
Please be aware that this is a workaround, I'm not 100% sure it doesn't break some functionalities of Yoast I'm not aware of!
@lorenzolago Many thanks, that works!
A minor correction for anyone else coming here, the path should be /wp-content/plugins/cmb-field-select2/js/select2.min.js
.
Also, I found a little extra admin CSS was necessary:
.select2-selection__choice {
padding-left: 25px !important;
}
But much appreciated. I'll not close this issue since it's a workaround, though.
Using this add-on for the CMB2 plugin - https://github.com/mustardBees/cmb-field-select2 - Yoast seems to intefere with its implementation of the Select2 jQuery interface, meaning that the drag-and-drop ordering for selections aren't maintained by that add-on.
When selected items in a
pw_multiselect
field are re-ordered, the ordering should be maintained after saving the post. However, drag-and-drop seems to generate a JS error, due to interference by Yoast SEO code, meaning the ordering is not maintained.I've reported the issue to cmb-field-select (https://github.com/mustardBees/cmb-field-select2/issues/52) but it looks like the issue is Yoast code interfering with that plugin's markup.
How can we reproduce this behavior?
pw_multiselect
field as per instructions (https://github.com/mustardBees/cmb-field-select2#usage)Technical info
What seems to be happening is that code in Yoast's
select2.full.min.js
is rewriting list elements for Select2 elements, and the cmb-field-select element is getting caught up in this. The elements end up withdata-select2-id
attributes, but the ID in the data that the cmb-field-select'sscript.js
(line 21) is looking for is gone, creating a JS error when a drag-and-drop happens.Used versions