Home › Forums › Backend Issues (wp-admin) › Dynamically populate Select Field with JSON › Reply To: Dynamically populate Select Field with JSON
This has nothing to do with your error. acf/load_field will work, but you should use acf/prepare_field to modify the choices. https://www.advancedcustomfields.com/resources/acf-prepare_field/. The reason for this is that when you use load_field the choices will by update and stored if you are using local json or you export the field group. When you use load_field you’re also running your filter in places it does not need to be run.
What is the critical error that’s being reported? That would help to figure out what’s wrong.
The only thing that I can see as in issue with your code is that
return $field;
is inside the if block. This means that of the results of
if( is_array($blogPosts) ) {
is not true then $field
well be set to NULL
because nothing is returned if the condition is false.
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.