Add ACF field name to admin with copy to clipboard

tdrayson

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.

business details ‹ the creative tinker — wordpress httplocalhost10023wp adminadmin.phppage=theme business details 2024 08 06 at 2.30.11 pm

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.

Members content only

Become a snippetclub.com member to gain instant access to this tutorial plus tons more premium content.

Already a member? Log in below.

Login Form

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise