Home › Forums › Backend Issues (wp-admin) › Tabs β On save post, bouncing back to first tab › Reply To: Tabs β On save post, bouncing back to first tab
A little late here, but an easy JS solution I created is this:
jQuery(function(){
function parseHash(){var hash=window.location.hash.substring(1),params={};if(hash.length<5){return params;}var vars=hash.split('&');for(var i=0;i<vars.length;i++){if(!vars[i]){continue;}var pair=vars[i].split('=');if(pair.length<2){continue;}params[pair[0]]=pair[1];}return params;},
var hashData=parseHash();
if(hashData&&hashData.acf_tab){jQuery('a.acf-tab-button[data-key="'+hashData.acf_tab+'"]').trigger('click');jQuery('form#post').attr('action','#&acf_tab='+hashData.acf_tab);}
jQuery('a.acf-tab-button').on('click',function(event){window.location.hash='&acf_tab='+jQuery(this).data('key');jQuery('form#post').attr('action','#&acf_tab='+jQuery(this).data('key'));});
});
Just add that anywhere in the admin area of your site through an action/filter. Here’s an example of that for your functions.php file:
add_action( 'admin_enqueue_scripts', array(__CLASS__,function(){
wp_enqueue_script( 'psAdminCustom', get_template_directory_uri() . '/admin/custom.js', array(), '2.0.0', false );
} ) );
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βre excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
π #ComposerPHP fans rejoice!
β¨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.