On a recent project I’ve been working on, I’ve been building out a template for a post type with lots of ACF field names. It was really frustrating not being able to know what the field names I needed to use for which data. It only showed me the label.
I wrote a small snippet that adds the field name next to the label and allows you to click the button to copy it to your clipboard.
1. Adding our code to the label
First we have our PHP function which adds the field name to the label markup. We have an $exclude_types
array which we can add any field types that we want to exclude from being targeted. This code will also only display for users that have administrator role.