Support

Account

Home Forums Add-ons Repeater Field get_field() for repeater returning string instead of array Reply To: get_field() for repeater returning string instead of array

  • @rkirkner in your case, the functions like get_field() are defined when the files for ACF are loaded, but ACF does not load any field type definitions until the WP init hook and many of the functions that do the work are not defined until have this as well, for example the field classes that define each field type are not initialized. ACF has another hook that fires during init, this is the action acf/include_field_types. This hook fires somewhere during the initialization phase of ACF and no field types are defined before this happens. This can cause the error that your seeing because the “repeater” is not defined so ACF does not know how to handle the content of the field value that is returned by get_field(). The main reason that nothing can really be done before the acf/init hook is fired is that ACF can be included in the theme and the good place for ACF to start it’s magic is on the init hook.

    If you need to do things before this, for example you need an option value to initialize something in your plugin, then it is better to use something like get_option() or even get_post_meta()