Home › Forums › ACF PRO › Error adding action to acf/load_field › Reply To: Error adding action to acf/load_field
Thanks for the suggestions. You set me on the right path. I had wp_reset_postdata in there originally but I guess I deleted it when I trimmed down my code.
I can’t believe that I didn’t notice I was using add_action when I should have been using add_filter. Glad you pointed that out or I would have had even more problems. Turns out though, that isn’t actually what was at the root of my problem either.
I *think* that I’ve figured this out. I say this a bit hesitantly because I have had no end of problems with this particular item. It would appear that the problem was, having two fields with the same name referencing them. Basically even after I changed it to add_filter I was still having the same problem, but I noticed that I was able to work around the problem by using get_post_meta instead. But the data being returned was wrong.
Long story short, I opened up the field group, noticed a whole bunch of field groups, and then had the sudden “eureka” moment that two fields being referenced had the same name and might be stepping on each others’ toes. Sure enough when I update the field names so that they are not identical, things start working as they should. Or at least, so it would seem. I guess if you have a filter applied to acf/load_field/name=make then it gets applied to all fields with that name. Which makes total sense.
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βre excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
π #ComposerPHP fans rejoice!
β¨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.