Home › Forums › Add-ons › Repeater Field › get_field repeater not returning array › Reply To: get_field repeater not returning array
This can also happen if you call get_field too early, I had a case where I called it at the top of the functions.php file in a $_GET check and it wouldn’t load the data for a repeater field, just the number of elements.
For Example:
if( $_GET['dostuff'] == 'yes'){
$data = get_field('fieldname', 'option');
//do stuff
//$data returned "3"
}
I solved this by moving it to a function in an init action
if( $_GET['dostuff'] == 'yes'){
add_action('init', 'functionname');
}
function functionname(){
$data = get_field('fieldname', 'option');
//do stuff
//$data returned array
}
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.