For a client’s site we wanted to add some ACF fields to the Edit Term page for global attributes. If the attribute list were fixed, this would be a simple task of targeting the specific taxonomies in the field group’s location parameter. What complicated this particular instance is that we wanted ALL attribute edit pages to have these custom fields and the client had the ability to add or remove attribute via the admin. This meant that we had to be able to gather all the attribute types and target them for our field group.

This turned out to be a fairly straight-forward task. By using the WooCommerce function wc_get_attribute_taxonomy_names() we can create a set of location rules that are dynamically created which will target all existing global attribute types.

Here is the complete code which will add a tab and sample image field to all global attribute Term Edit pages:

 

Comments are closed.