Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix for Advanced Custom Fields high priority
// Move elements around screen.
acf.addAction('prepare', function(){
// Use setTimeout to make sure field is loaded
setTimeout(function(){
// Move #acf_after_title-sortables after
// Post Title box and add classes and css for styling
// and presentation
$('.editor-post-title').after(
$('#acf_after_title-sortables')
.addClass('wp-block')
.css('margin', '20px auto 40px')
);
}
, 1000);
// On save create copy of #acf_after_title-sortables and inset in #poststuff
$(document).on('click','.editor-post-publish-button', function(){
// Check if container in postbox is created
if($('#poststuff .postbox-container #acf_after_title-sortables-copy').length){
$('#poststuff .postbox-container #acf_after_title-sortables-copy').html(
// Update form with data
$('#acf_after_title-sortables').html()
);
}else{
// Create clone of #acf_after_title-sortables and insert in #poststuff
$('#acf_after_title-sortables')
.clone()
.attr('id','acf_after_title-sortables-copy')
.hide()
.appendTo( $('#poststuff .postbox-container') );
}
});
}, 1);
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.