Skip to content

Instantly share code, notes, and snippets.

@hapidjus
Last active June 29, 2020 11:46
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 hapidjus/4137bfd37f0d59a5aa4d7b62143ca265 to your computer and use it in GitHub Desktop.
Save hapidjus/4137bfd37f0d59a5aa4d7b62143ca265 to your computer and use it in GitHub Desktop.
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