Support

Account

Home Forums Backend Issues (wp-admin) Active Tab Dependant on Category

Solved

Active Tab Dependant on Category

  • Is there a hook or something where I can set an active tab ( admin side ) whenever the post is assigned to a specific category?

    I guess if there’s really no way I can create a hidden field, fill it with a category ID on save, and use the conditional switch on the tab but I’m hoping for an alternative.

  • You need to add an event to a trigger on the field. For the standard WP category box you need to add an action when something there is changed. For an ACF taxonomy field you need to add an action to the change event of that field. Take a look at the jQuery docs for .on(), .bind(), .click(), etc. There are probably dozens of ways this can be done but really nothing to do with ACF.

    As far as making a specific tab active, all you really need to do is trigger the click event for that tab in the action you add to the other element. For example, if I have an acf field group with the group key of group_586cf71a7742c and a tab with a field key of field_586d38c5329b5

    
    $('#acf-group_586cf71a7742c .acf-tab-wrap [data-key="field_586d38c5329b5"]').trigger('click');
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.