Having written plugins that extend the very popular WordPress plugin Advanced Custom Fields (ACF), I’ve come up against the need to work out a field’s key based on its field name.
This normally comes up when structuring data for programmatic field update as ACF needs to the values mapped to field keys when updating complex fields such as repeaters, flexi-fields, etc.
If you find yourself needing to update a complex field using ACF’s built-in update_field()
function, you should find the following to be quite useful.