Home › Forums › Bug Reports › Attachment Taxonomy Multi-Select not saving › Reply To: Attachment Taxonomy Multi-Select not saving
This code fixes the WordPress save function. I have also submitted this as a bug so hopefully they fix it.
add_action( 'admin_print_footer_scripts', 'mediaArrayFix', 11 );
function mediaArrayFix() {
// Make sure the media-views script has been enqueued.
if(!did_action( 'wp_enqueue_media' ) ){ return; }
?>
<script>
wp.media.view.AttachmentCompat.prototype.save = function( event ) {
var data = {};
if ( event ) { event.preventDefault(); }
_.each( this.$el.serializeArray(), function( pair ) {
if ( /\[\]$/.test( pair.name ) ) {
if ( undefined === data[ pair.name ] ) { data[ pair.name ] = []; }
data[ pair.name ].push( pair.value );
}else{ data[ pair.name ] = pair.value; }
});
this.controller.trigger( 'attachment:compat:waiting', ['waiting'] );
this.model.saveCompat( data ).always( _.bind( this.postSave, this ) );
};
</script>
<?php
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.