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()
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.