Support

Account

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.