Could you please tell me the location rule of the field group? Was it the post, page, taxonomy, or anything else?
Basically, if you call a custom field outside The Loop, you need to provide the ID of the object where you set the location rule. So, if you set the rule to a post, you need to do it like this:
$terms = get_field('taxonomy_field_name', 99);
Where “99” is the ID of the post. If set the location rule to taxonomy, it has different ID structure. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/.
I hope this helps 🙂
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've just released ACF 5.12.3 with a security fix to prevent arbitrary file uploads to forms with ACF fields.— Advanced Custom Fields (@wp_acf) July 14, 2022
Now that we've released this update, we recommend updating your sites as soon as possible.
© 2022 Advanced Custom Fields.