Home › Forums › General Issues › Creating theme fields – generating a key? › Reply To: Creating theme fields – generating a key?
Great questions
1. The field_key can be ANYTHING you want but MUST start with field_
2. To generate a key in the same way that ACF does, use this:
$key = 'field_' . uniqid();
3. You can create function which returns an array (1 single field), and then call this function when you want the field. This is a way to include 1 field in multiple field groups. It will use the same field key, and that’s fine because the field_key is only used to load the field object and use it’s settings to modify the interface and value.
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.