@tulip I had a similar issue which was caused by have_rows() running too early in my code. Ensure that it’s after WP has loaded the plugins and it should hopefully fix it.
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
}
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
}
Options Page with a Repeater field is not working – doing a get_field(‘repeaterfield’,’option’); returns the number of rows instead of the usual array of sub-fields. have_rows(‘repeaterfield’, ‘option’) while or ifs do not work at all. This appears to be a bug.
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.