Home › Forums › General Issues › Retrive field_key outside the loop › Reply To: Retrive field_key outside the loop
As far as I know there isn’t a way to get a field object by the field name when there is nothing already in the database for that field.
Instead of using the field name in get_field_object, use the field key, or in this case, just hard code the field key for that field.
In ACF, multiple fields can have the same name. ACF does not know which field to get unless it can get the key form the database for whatever object the field is attached to, like a post or term or options.
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.