logomichael sumner
Contact

How to Hide ACF Repeater Sub Field in Admin Edit Screen

There wasn’t any reference around the internet (that I could find) about this, so I thought I would share the code that I used to easily hide specific ACF repeater or group sub fields in the admin edit screen. Advanced Custom Fields certainly is a great plugin!

You will have to place this code either in the plugin ‘Code Snippets’, or in your functions.php file:

  • replace {sub_field_name} with your sub_field_name that needs hiding in the Admin Edit Screen
  • replace {sub_field_key_to_hide} with the field key of your sub_field_name. You can find the accompanying field key by right-clicking the sub field’s name, click ‘Inspect’, and finding the data-key attribute.
  • replace {sub_field_key_1} and {sub_field_key_2} and any more or any less sub fields within your repeater/group, with their associated field keys too
  • replace the CSS width value found in the code, with 100% / the number of remaining visible sub fields. For example, if you have only 1 sub field left to show, then this will be 100% / 1 = 100% width
/**
 * Hide `{sub_field_name}` using sub field key `{sub_field_key_to_hide}`
 * @since 5.6.10
 * @link https://blog-internal.sumner.co.uk/?p=1590
 * @author Michael Sumner
 */
function my_theme_hide_acf_{sub_field_name}_admin_head() {
	?>
	
	<?php
}

add_action('acf/input/admin_head', 'my_theme_hide_acf_{sub_field_name}_admin_head');

Further Customisation

You may further customise this by conditionally loading the CSS when on a certain post type that uses these ACF sub fields. But for the most part it will be okay to load multiple inline styles in the admin_head, giving into consideration that every field_key essentially is unique, therefore no conflicts will be found.

Hope this helps!

Please let us know in the comments if you may have a better way to hide and style the ACF sub fields.