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.
A function for finding a sub-field key based on its field name
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters