Get an ACF sub-field key by field name

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.

One last thing…

If you liked this article, I'd be incredibly grateful if you tweeted about it.

Also, I don't send emails often but when I do, I try to fill them full of useful goodies. If you like code snippets & dev tips, join my mailing list. There's no catch but I'll probably want to tell you about any new plugins & tools I build.